html(玉)包含
body(ng-controller='myAppController')
<input ng-model="inputQuery">
ul
li(ng-repeat="phone in phones|filter:query") {{phone.name}}
p {{phone.snippet}}
控制器定义为:
function myAppController($scope){
$scope.query = function(item){
return item.name.contains('$scope.inputQuery') ;
}
$scope.phones = [
{"name": "Nexus S",
"snippet": "Fast just got faster with Nexus S."},
{"name": "Motorola XOOM™ with Wi-Fi",
"snippet": "The Next, Next Generation tablet."},
{"name": "MOTOROLA XOOM™",
"snippet": "The Next, Next Generation tablet."}
];
}
输出应该是“电话”,其“名称”包含“输入”字母。但是没有输出。(根据输入也没有变化)
经检查,以下工作:
$scope.query = function(item){
return item.name; // or return item
}
但即使return item.name.contains('N');
不起作用