JSFiddle - React, Tailwind, and code Playground
HTML
<body ng-app="app" ng-init="value=0">
<button ng-click="value=1">Set value to 1</button>
<test-directive activate="value"></test-directive>
</body>
JavaScript
var app = angular.module('app', []);
app.directive('testDirective', function() {
return {
restrict: 'E',
scope: {
activate : '='
},
link: function(scope, elem, attrs, controller) {
var el = elem[0];
var updateContent = function() {
el.innerText = 'Activate=' + scope.activate;
};
scope.$watch( 'activate', function(value) {
console.log('Activate=', value);
if(value === 1) {
scope.activate = '0'
}
updateContent();
});
}
}
});