Angular JS - 在HTML指令中使用JSON对象的条件语句

时间:2014-03-10 14:09:37

标签: angularjs angularjs-directive

我有一个JSON对象,格式如下:

{
   filters: [
        {Name: "pork",
         Active: true},
        {Name: "beef",
         Active: true},
        {Name: "chicken",
         Active: false}
   ]
}

我正在使用以下内容构建SELECT列表:

ng-options="item.Name for item in filters"

如果“有效”键为true,我只想构建一个选项。有没有办法让我在Angular指令的psuedo-JavasScript里面这样做?

1 个答案:

答案 0 :(得分:1)

尝试ng-options="item.Name for item in filters | filter:{ Active : true }"