嗨,我有一个像这样的json数组
var homes = [
{
"city": "Dallas",
"state": "TX",
"zip": "75201",
"NoteNumber": "162500"
}, {
"city": "Bevery Hills",
"state": "CA",
"zip": "90210",
"NoteNumber": "319250"
}, {
"city": "New York",
"state": "NY",
"zip": "00010",
"NoteNumber": "null"
}
];
我使用div
ng-repeat
中显示它们
<div ng-repeat="name in homes">
{{name.city}}
</div>
我有html select
标记,其中包含选项notenumber
和null
如果选择了notenumber,请告诉我如何显示只有notenumber
的城市,如果选择为null,则只显示null
个非城市。
答案 0 :(得分:1)
使用绑定到SELECT
的另一个范围var过滤数组<select ng-model="selectedNoteNumber">YOUR OPTIONS HERE</select>
<div ng-repeat="name in homes | filter: { 'NoteNumber': selectedNoteNumber }">
{{name.city}}
</div>
答案 1 :(得分:0)
你可以试试这个
<select ng-model="NoteNumber" ng-options="homes.NoteNumber as homes.NoteNumber for NoteNumber in homes"> </select>
<div ng-repeat="name in homes">
<span ng-if="NoteNumber !== 'null'">{{name.city}}</span>
</div>
希望这有帮助