2014-05-13 5 views

답변

1

대신 사용 대상 :

myApp.controller("PatientCtrl", function($scope) { 
    $scope.viewModel = { patientSwitch: "edit" }; 
}); 

그리고 :

<span ng-switch on="viewModel.patientSwitch"> 
    <span ng-switch-when="edit"> 
     <button ng-click="viewModel.patientSwitch='save'">save</button> 
    </span> 
    <span ng-switch-when="save"> 
     <button ng-click="viewModel.patientSwitch='edit'">edit</button> 
    </span> 
</span> 

데모 :http://jsfiddle.net/M7EX2/

ngSwitch은 객체를 사용하지 않으면 JavaScript에서 프로토 타입 상속이 작동하는 방식으로 인해이 문제가 발생한다는 것을 의미하는 새로운 범위를 만듭니다.

매우 좋은 게시물은 here입니다.