无法使 Angular 个过滤器正常工作 ng-options
Unable to get Angular filters working ng-options
所以我正在使用 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 过滤我正在创建的 select 列表选项,以仅获取具有 Group.Name == "CorporateProject" 的值。我尝试了以下多种变体,但似乎无法正确过滤:
<select ng-model="test" ng-options="c as c.text for c in properties.Consultants| filter:{Group.Name: 'CorporateResource'}"></select>
我不断收到以下 js 错误:
你的过滤器有误,应该如下所示
ng-options="c as c.text for c in properties.Consultants
| filter: {Group: {Name: 'CorporateResource'}}"
所以我正在使用 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 过滤我正在创建的 select 列表选项,以仅获取具有 Group.Name == "CorporateProject" 的值。我尝试了以下多种变体,但似乎无法正确过滤:
<select ng-model="test" ng-options="c as c.text for c in properties.Consultants| filter:{Group.Name: 'CorporateResource'}"></select>
我不断收到以下 js 错误:
你的过滤器有误,应该如下所示
ng-options="c as c.text for c in properties.Consultants
| filter: {Group: {Name: 'CorporateResource'}}"