我使用AngularJs 1.3.4
$scope.change = function (id) {
console.log("test onChange... " + id);
};
<input ng-change="change({{question.id}})"
还可以
但<input ng-blur="change({{question.id}})"
有语法错误
Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 9 of the expression [change({{question.id}})] starting at [{question.id}})].
http://errors.angularjs.org/1.3.4/$parse/syntax?p0=%7B&p1=invalid%20key&p2=9&p3=change(%7B%7Bquestion.id%7D%7D)&p4=%7Bquestion.id%7D%7D)
at http://localhost:8080/bower_components/angular/angular.js:63:12
您根本不应该在调用中使用“ {{var}}”,角度自动在范围内进行插值。您需要做的是:
<input ng-blur="change(question.id)" />
我的猜测是ng-blur和ng-change以不同的方式处理它们,因为这违反了标准。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句