trying to test a simple directive that will run if passed value is true but it works only once.
directive:
.directive('myDirective', function(){
return {
restrict: 'A',
scope: {
triggerObj: '@myDirective'
},
link: function (scope, elem, attrs) {
scope.$watch('triggerObj', function() {
alert('success')
});
}
};
})
controller:
$scope.triggerObj = {};
$scope.triggerObj.trigger = false;
$scope.passValue = function(){
//set to true
$scope.triggerObj.trigger = true;
}
view:
<div my-directive='{[triggerObj.trigger]}'>
<button type='button' ng-click='passValue()'>click</button>
also tried to reset value to false before setting to true but still it works only once.