我正在尝试探索AngularJS
过滤器,但我正在尝试的代码无效。
JSFiddle也是如此:http://jsfiddle.net/sajesh1985/5bp5v1z0/1/
<td><input type="text" ng-model="search.Name"/></td>
<tbody ng-repeat="item in items ">
<tr ng-repeat="temp in item | filter:search">
<td>{{temp[0].Name}}</td>
<td>{{temp[0].Price}}</td>
<td>{{temp[0].Quantity}}</td>
</tr>
</tbody>
答案 0 :(得分:0)
我认为你的item对象构造得不是很好,我认为它应该像这样
$scope.items = [
{
Name: "Account Opening R75",
Price: "R75",
Quantity: "A_O-AngularJS"
}
,
{
Name: "AVClientService",
Price: "R74",
Quantity: "AVClientService-DotNet"
}
];
另外,我修改了你的代码snnipet:
<tr ng-repeat="item in items | filter:search">
<td>{{item.Name}}</td>
<td>{{item.Price}}</td>
<td>{{item.Quantity}}</td>
</tr>
对于完整示例,请检查此jsfiddle http://jsfiddle.net/5bp5v1z0/3/
希望它有所帮助!