2014-07-12 59 views
0

我是AngularJS的新手,我猜想有一个非常基本的问题。AngularJS中的数据绑定

我有一个下拉列表,并根据选择我想要一个表下方更新所属信息。

<div ng-controller="RightCtrl as right"> 
    <select ng-model="right.selectedModule"> 
    <option ng-repeat="module in right.modules" value="{{module.id}}">{{module.name}} 
    </option> 
    </select> 
    <table> 
    <thead> 
    <th>Right name</th> 
    <th>Description</th> 
    </thead> 
    <tbody ng-repeat="module in right.modules | filter: right.isCurrent"> 
    <tr ng-repeat="selRight in module.rights"> 
    <td right-id="{{selRight.id}}">{{selRight.name}}</td> 
    <td> 
     {{selRight.description}} 
    </td> 
    </tr> 
    </tbody> 
    </table> 
</div> 

我有一个jsfiddle(http://jsfiddle.net/EN3S9/),并感谢每一个帮助。可能我还没完全理解这个概念。

回答

1

我想你在找什么是要根据选择的对象像过滤:

<tbody ng-repeat="module in right.modules | filter:right.selectedModule"> 

以下是完整的演示:

Online Demo

+0

太好了!谢谢!我想我还没有明确过滤器是如何工作的。过滤器如何知道要过滤的参数? – Phil