ng-switch未按预期切换

时间:2015-04-28 14:59:30

标签: angularjs

我似乎错过了ng-switch的基本内容。这是一个jsFiddle

我试图启用profile_type但我无法启用。

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

1 个答案:

答案 0 :(得分:4)

缺少某些东西,找到这一行并改变它:

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