所以我正在使用Angular版本1.5.7并从服务器接收一个看起来像这样的对象:
var app = angular.module('myApp', []);function ctrl($scope){
$scope.properties.Consultants = [
{
text:"consultant1",
Group: {Name:"CorporateResource", Disabled:"False"}
},
{
text:"consultant2",
Group: {Name:"CorporateResource", Disabled:"False"}
},
{
type:"consultant3",
Group: {Name:"Resource", Disabled:"False"}
},
{
type:"consultant4",
Group: {Name:"Resource", Disabled:"False"}
}
];
}
我需要过滤基于Group.Name创建的选择列表选项,只获取具有Group.Name ==" CorporateProject"的值。我尝试了以下的许多变体,但似乎无法正确过滤:
<select ng-model="test" ng-options="c as c.text for c in properties.Consultants| filter:{Group.Name: 'CorporateResource'}"></select>
答案 0 :(得分:1)
你有错误的过滤器,它应该如下所示
ng-options="c as c.text for c in properties.Consultants
| filter: {Group: {Name: 'CorporateResource'}}"