Frage

My HTML code is

<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">
                -&nbsp;{{cred.userName}}&nbsp;/&nbsp;{{cred.password}}
            </div><br />
        </td>
    </tr>

Which is not binding data... (TD s and text is present but binding property values are empty)

How to work with ng-switch-when and ng-repeat at a time?

Thanks in advance

War es hilfreich?

Lösung 2

This is by design. Please see https://stackoverflow.com/a/15434085/1264360. Basically to fix you need to have the ng-switch-when in an element above the ng-repeat.

Andere Tipps

ng-switch requires a parent to have a

ng-switch on="variableName"

and children to have

ng-switch-when="stuff1" 

Example with 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>

and your collection for ng-repeat might look like:

$scope.values = {
    one: {color: 'blue', worth: 2},
    two: {color: 'green', worth: 3},
    three: {color: 'orange', worth: 4},        
}

http://plnkr.co/edit/YavzpaPUBaBQNA0pHMPN?p=preview

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top