JSON:
$scope.results=[
{
id: 1,
name: null,
class: "First"
},
{
id: 2,
name: John,
class: "First"
},
{
id: 3,
name: Mary,
class: "Second"
},
{
id: 4,
name: null,
class: "Third"
}
]
HTML:
<div class="col-md-6 form-group" data-ng-repeat="item in results| filter:{name:'!null'}">{{item.name}}</div>
我想过滤掉name
值null
的数据。我的代码出了什么问题?
答案 0 :(得分:0)
通过添加这段代码来解决它:
<div class="col-md-6 form-group" data-ng-repeat="item in results| filter:{name:'!!'}">{{item.name}}</div>
答案 1 :(得分:0)
你的json formate不合适试试这个
plunker link http://plnkr.co/edit/H94f6XhyyhbvJ3F25NoA?p=preview
$scope.results=[
{
id: 1,
name: null,
class: "First"
},
{
id: 2,
name: "John",
class: "First"
},
{
id: 3,
name: "Mary",
class: "Second"
},
{
id: 4,
name: null,
class: "Third"
}
];