ng-switch-when with ng-repeat

All we need is an easy explanation of the problem, so here it is.

My HTML code is

<tr ng-switch-when="true" ng-repeat="onlineCredentials in onlineCredentialDetails" >
            <span>Ordering Mode: </span>{{onlineCredentials.mode}}<br />
            <span>Intermedtiary Group: </span>{{}}
            <span>Website: </span>{{onlineCredentials.webSite}}
        <td >
            <span>Username / Password</span>
            <div ng-repeat="cred in onlineCredentials.loginDetails">
            </div><br />

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

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

ng-switch requires a parent to have a

ng-switch on="variableName"

and children to have


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>

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},        

Method 2

This is by design. Please see Basically to fix you need to have the ng-switch-when in an element above the ng-repeat.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply