2015-04-28 28 views
2

我似乎在这里缺少一些基本的东西ng-switch。这是一个jsFiddleng-switch没有按预期切换

我试图打开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"}, 
] 

回答

4

有遗漏,找到这一行并改变它像这样:

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