Я пытался посмотреть переменную scope внутри контроллера директив, который я ввел через шаблон. Но слушатель никогда не запускается.Watch in directives controller not working
http://plnkr.co/edit/a9UWiVZlKhaKf0Z0utSG?p=preview
var angularSimpleAuth = angular.module('angularSimpleAuth', []);
angularSimpleAuth.directive('simpleAuthUsername',function(){
return {
restrict: 'A',
scope:{},
template:'<input type="text" ng-model="userName" />',
controller:function($scope){
$scope.$watch('userName',function(val){
console.log('Value'+val);
});
},
link: function($scope, elem, attrs,controllers) {
console.log('In link for username');
}
};
})
Может кто-нибудь сказать мне, что я делаю неправильно here.Any помощь оценили Благодаря
Это работало также делает замену истинна на моей директиве атрибута также worked.Could скажите, пожалуйста, что происходит! здесь. Спасибо за ответ –