I have this factory,
.factory('authentication', [function() {
return {
loginRequired: false
};
}]);
I have this controller,
.controller('TopNavCtrl', ['$scope', 'authentication', function($scope, authentication) {
$scope.login = function() {
authentication.loginRequired = true;
};
}]);
and I have this link function in a directive,
link: function(scope, element, attrs) {
scope.show = false;
scope.$watch(authentication.loginRequired, function(value) {
scope.show = value;
});
}
When authentication.loginRequired = true;
is done in the controller, the scope.$watch
in the directive isn't called.
Any ideas why?