按angularjs中的选定选项过滤帖子

时间:2014-11-22 07:00:07

标签: angularjs angularjs-directive

<div class="ng_wrapper"
data-ng-init="portfolios=[
{name: 'Portfolio 1', type: 'red'},
{name: 'Portfolio 2', type: 'red'},
{name: 'Portfolio 3', type: 'black'},
{name: 'Portfolio 4', type: 'black'}
]">    
    <ul>            
        <li data-ng-repeat="portfolio in portfolios | filter:type ">
        {{ portfolio.name | uppercase }} - [{{ portfolio.type | lowercase }}]
        </li>
    </ul>
<select><option>red</option><option>black</option></select>
</div>

如何根据&#39;类型&#39;进行过滤选择?当我选择红色时,我想只显示红色投资组合。我怎么能这样做?

由于

1 个答案:

答案 0 :(得分:1)

您可以向ng-model添加Drop-down属性,并在filter的{​​{1}}中引用该属性

ng-repeat

工作演示:http://plnkr.co/edit/5md1XYgNhrxWUWW8CwDc?p=preview