title: How to update the input text value using custom Directive in angularjs
body: <p>I am newer in angularjs. I am just trying to update the input txt value using custom Directive. But i cant. Here i have showed my code What i did wrong this code. Some one help me and explain how it is working.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var myApp = angular.module('myApp',[]);
  
  //myApp.directive('myDirective', function() {});
  //myApp.factory('myService', function() {});
  myApp.controller('MyCtrl',MyCtrl);
  function MyCtrl($scope) {
      $scope.name = 'Superhero';
      $scope.myTime = '10:59';
  }
  
  
  myApp.directive('myDirective', function () {
      return {
          restrict: 'A',
          require: '?ngModel',
          link: function (scope, element, attrs, ngModel) {
              scope.$watch(attrs.ngModel, function (v) {
                  console.log('value changed, new value is: ' + v);
                 ngModel.$setViewValue('11')
                 //scope.ngModel = '11'
                 
              });
          }
      };
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"&gt;&lt;/script&gt;
  &lt;div ng-controller="MyCtrl"&gt;
    Hello, {{name}}!
      
      
      &lt;input type="text" my-directive ng-model="myTime" name="customTime"&gt;
      
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>