Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 在自定义指令中使用ng模糊_Angularjs_Angular Directive - Fatal编程技术网

Angularjs 在自定义指令中使用ng模糊

Angularjs 在自定义指令中使用ng模糊,angularjs,angular-directive,Angularjs,Angular Directive,我在自定义指令中使用ng blur时遇到问题。我想要的是能够制作一个组件,该组件可以处理发送到指令的ng blur属性中的任何类型的函数 以下是指令示例: <az-dir ng-blur="change()" lid="test" ng-model="obj.test"></az-dir> 简单角度控制器: var app = angular.module('ashtest', []); app.controller('TopCtrl', ['$scope', f

我在自定义指令中使用ng blur时遇到问题。我想要的是能够制作一个组件,该组件可以处理发送到指令的ng blur属性中的任何类型的函数

以下是指令示例:

<az-dir ng-blur="change()" lid="test" ng-model="obj.test"></az-dir>
简单角度控制器:

var app = angular.module('ashtest', []);

app.controller('TopCtrl', ['$scope',
  function($scope) {

    $scope.obj = {
      test: "Ashkan"
    };

    $scope.change = function() {
      $scope.obj.test = "changedThis";
    }


  }
]);
ngBlur:“&”

解释如下:

@文本绑定/单向绑定 =直接模型绑定/双向绑定 &行为绑定/方法绑定
在我的plunker上试试,如果你用“&”的话,它不会触发。这对我来说太棒了!这就是我所缺少的。谢谢
var app = angular.module('ashtest', []);

app.controller('TopCtrl', ['$scope',
  function($scope) {

    $scope.obj = {
      test: "Ashkan"
    };

    $scope.change = function() {
      $scope.obj.test = "changedThis";
    }


  }
]);