甚至可以使用Integer进行过滤。我有一个列表,其中搜索工作正常,除了一个字段,即整数。我尝试在JsFiddle中做几乎相同的情况,但我甚至不能让ng-repeat工作:)
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.min.js"></script>
<body ng-app="">
<div ng-init="rmas = [
{
brand: "TIK",
extraInfo: "lisäinfoa",
isWarranty: false,
litm: "T00000245",
lotn: "00004",
model: "A10499",
retailer: 40001,
retailerName: "mr Retailer",
rmaId: 1},
{
brand: "SAK",
extraInfo: "LISÄÄÄ",
isWarranty: false,
litm: "S2181105",
lotn: "003500",
model: "A30340",
retailer: 40011,
retailerName: "MALL SAM",
rmaId: 2
},
{
brand: "TIK",
extraInfo: "LISÄÄÄ",
isWarranty: false,
litm: "T00000245",
lotn: "00004",
model: "A10499",
retailer: 40000,
retailerName: "ULF SVENSSON",
rmaId: 3
}
]"></div>
<div ng-init="friends = [{name:'John', phone:'555-1276'},
{name:'Mary', phone:'800-BIG-MARY'},
{name:'Mike', phone:'555-4321'},
{name:'Adam', phone:'555-5678'},
{name:'Julie', phone:'555-8765'},
{name:'Juliette', phone:'555-5678'}]"></div>
<label>Search: <input ng-model="searchText"></label>
<table id="searchTextResults">
<tr><th>rmaId </th> <th> retailerName </th><th> litm</th></tr>
<tr ng-repeat="rma in rmas | filter:searchText"">
<td>{{rma.rmaId}}</td>
<td>{{rma.retailerName}}</td>
<td>{{rma.litm}}</td>
</tr>
</table>
<table id="searchTextResults">
<tr><th>Name</th><th>Phone</th></tr>
<tr ng-repeat="friend in friends | filter:searchText">
<td>{{friend.name}}</td>
<td>{{friend.phone}}</td>
</tr>
</table>
<hr>
</body>
&#13;
答案 0 :(得分:0)
所以我纠正了你的一些错误并把你的数据放在控制器中,这里是working codepen
我认为你的错误是你使用&#34;在ng-Init中只使用这样的单引号:
<div ng-init="rmas = [
{
brand: 'TIK',
extraInfo: 'lisäinfoa',
isWarranty: false,
litm: 'T00000245',
lotn: '00004',
model: 'A10499',
retailer: '40001',
retailerName: 'mr Retailer',
rmaId: 1},
]"></div>