我的HTML代码是
<tr ng-switch-when="true" ng-repeat="onlineCredentials in onlineCredentialDetails" >
        <td>
            <span>Ordering Mode: </span>{{onlineCredentials.mode}}<br />
            <span>Intermedtiary Group: </span>{{onlineCredentials.name}}
        </td>
        <td>
            <span>Website: </span>{{onlineCredentials.webSite}}
        </td>
        <td >
            <span>Username / Password</span>
            <div ng-repeat="cred in onlineCredentials.loginDetails">
                - {{cred.userName}} / {{cred.password}}
            </div><br />
        </td>
    </tr>这不是绑定数据...(TD %s和文本存在,但绑定属性值为空)
如何同时使用ng-switch-when和ng-repeat?
提前感谢
发布于 2014-05-06 21:40:47
这是设计好的。请参阅https://stackoverflow.com/a/15434085/1264360。基本上,要解决这个问题,您需要在元素中使用ng-switch-when高于ng-repeat。
发布于 2014-05-06 21:15:15
ng-switch要求父级具有
ng-switch on="variableName"和孩子们
ng-switch-when="stuff1" 使用ng-repeat的示例
<div ng-repeat="value in values" ng-switch on="value.color">
    <div ng-switch-when='blue'>Blue</div>
    <div ng-switch-when='green'>Green</div>
    <div ng-switch-when='orange'>Orange</div>
</div>您的ng-repeat集合可能如下所示:
$scope.values = {
    one: {color: 'blue', worth: 2},
    two: {color: 'green', worth: 3},
    three: {color: 'orange', worth: 4},        
}http://plnkr.co/edit/YavzpaPUBaBQNA0pHMPN?p=preview
https://stackoverflow.com/questions/23495052
复制相似问题