我有一个$ scope.myData对象,包含一大块数据.我想要做的是显示数据,但过滤掉空值和空字符串:
$scope.myData = [
{
"ID" : "001",
"Message" : "test test test test"
},
{
"ID" : "002",
"Message" : "test test test test"
},
{
"ID" : "003",
"Message" : "test test test test"
},
{
"ID" : "004",
"Message" : "test test test test"
},
{
"ID" : "005",
"Message" : " "
},
{
"ID" : "006",
"Message" : "test test test test"
},
{
"ID" : "007",
"Message" : "test test test test"
}, …Run Code Online (Sandbox Code Playgroud) angularjs angularjs-scope angularjs-ng-repeat angular-filters
我有以下设置
$scope.array =
[
{propertyA: "test",
propertyB: {
propertyC: [true, true, false]
}
},
{propertyA: "test2"},
{propertyA: "test3"}
]
Run Code Online (Sandbox Code Playgroud)
然后
<div ng-repeat="item in array| filter :{propertyB: ''} :true">
{{item.propertyA}}
</div>
Run Code Online (Sandbox Code Playgroud)
所以问题是:
此设置不显示任何内容
如果我换到|filter :{propertyB: '!!'} :true它不显示任何东西
如果我改变|filter :{propertyB: undefined} :true它显示一切
我无法弄明白.
目标:我想显示具有propertyB未定义的项目,而在其他情况下则显示相反的项目.
编辑1:如果我迭代这个数组与angular.equals(item.propertyB, undefined)我得到false, true, true
编辑2:jsfiddle UPDATED
编辑3:我已经更新了问题