在调用过滤器之前,如何对模型运行AngularJS函数?
这是一个简单的过滤器: 我试图在调用过滤器之前运行AngularJS函数。 但未触发ng更改事件。在调用过滤器之前,如何对模型运行AngularJS函数 src:在调用过滤器之前,如何对模型运行AngularJS函数?,angularjs,Angularjs,这是一个简单的过滤器: 我试图在调用过滤器之前运行AngularJS函数。 但未触发ng更改事件。在调用过滤器之前,如何对模型运行AngularJS函数 src: <input ng-change="changed" type="text" ng-model="search"> <ul ng-repeat="oneauth in authorisations | search"> {{entry.auth.name}} </ul> var app = an
<input ng-change="changed" type="text" ng-model="search">
<ul ng-repeat="oneauth in authorisations | search">
{{entry.auth.name}}
</ul>
var app = angular.module('myapp', [], function () {});
app.controller('AppController', function ($scope) {
$scope.authorisations = [
{
"auth":{
"number":"453",
"name":"Apple Inc."
}
},
{
"auth":{
"number":"123",
"name":"Microsoft Inc."
}
}];
$scope.changed = function(){
alert('changed');
}
});
{{entry.auth.name}
var app=angular.module('myapp',[],函数(){});
app.controller('AppController',函数($scope){
$scope.authorizations=[
{
“auth”:{
“编号”:“453”,
“名称”:“苹果公司”
}
},
{
“auth”:{
“编号”:“123”,
“名称”:“微软公司”
}
}];
$scope.changed=函数(){
警报(“更改”);
}
});
只需更换
<input ng-change="changed" type="text" ng-model="search">
与
希望它能起作用 您的代码中有两个错误: (一) 在ng repeat中指定过滤器:
ng-repeat="oneauth in authorisations | filter : search"
(二)
在ng change中指定函数:
ng-change="changed()"
这是工作票
ng-change="changed()"