I have been implementing a custom directive
<users stats="stats"></users>
Whenever the scope object is changed in the main controller, the directive's scope value is also updated.
app.directive('users', function(){
var directive = {};
directive.restrict = "E";
directive.templateUrl = "templates/partials/users_stats.html";
directive.scope = {stats:'='};
directive.controller = "userStatsCtrl"
return directive;
});
Within the directive controller, I have implemented some functions like:
app.controller("userStatsCtrl", function($scope){
$scope.$watch('stats', function(newValue) {
if (angular.isDefined(newValue)) {
.....
}
});
})
Currently, I am using $watch to monitor the scope changes. However, I would like to update the scope value without relying on scope.$watch.
My question is, how can I achieve this - updating the scope value without using scope.$watch?