user2954587
user2954587

Reputation: 4861

ng-switch not switching as expected

I seem to be missing something basic here for ng-switch. Here is a jsFiddle.

I'm trying to switch on profile_type but am unable to.

<div ng-controller="MyCtrl">
    <div ng-repeat="result in results">
        <div ng-switch="profile_type">
            <div ng-switch-when="PatientProfile">{{ result.name }}</div>
            <div ng-switch-when="DoctorProfile">{{ result.name }}</div>
        </div>
    </div
</div>

$scope.results = [
    {profile_type: "PatientProfile", name: "Steve Patient"},
    {profile_type: "DoctorProfile", name: "Joe Doctor"},
]

Upvotes: 2

Views: 28

Answers (1)

John Ding
John Ding

Reputation: 1350

Something is missing, find this line and change it like this:

<div ng-switch="result.profile_type">

Upvotes: 4

Related Questions