当我多次按下此按钮时,如何在按钮上执行$ watch()并触发my watch()?
HTML:
<button ng-click="addWatch()" style="margin-left:10px;" class="btn btn-danger btn-xs">
Re-init tableau
</button>
....
<mtx-matrice-form matrix="matrix " isclicked="isWatchAdded "></mtx-matrice-form>
js控制器:
$scope.addWatch = function(){
if( !$scope.isWatchAdded ) {
$scope.isWatchAdded = true;
}
}
指令:的
angular.module('matrixarMatrice', []).directive('mtxMatriceForm', function () {
return {
restrict: 'E',
templateUrl: 'views/matrice/matrice.html',
scope: {
matrix: '=',
isWatchAdded : '='
},
link: function (scope, element, attrs) {
...
$scope.$watch('isWatchAdded ', function () {}, true);
...
它按时运行我希望在点击我的按钮时运行