JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="myDirective" ng-controller="x">
<input id="angular" type="text" ng-model="data.test" my-directive>
</div>
<button onclick="document.querySelector('#angular').value = 'testg';">click</button>
JavaScript
angular.module('myDirective', [])
.directive('myDirective', function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
scope.$watch(attrs.ngModel, function (v) {
//console.log('value changed, new value is: ' + v);
alert('value change: ' + scope.data.test);
});
}
};
});
function x($scope) {
//$scope.test = 'value here';
$scope.data = {
test: 'value here'
}
}