2017-04-27 8 views
0

ng-switch으로 작성된 액세스 AT 모델 개체 인 여기에서 ng-switch은이 범위에서 자식 범위를 만들고 양식을 만듭니다. 따라서 자식 범위 형식은 부모 범위에서 사용할 수 없습니다. 도움은 angularjs ng-switch 자식 범위 형식을 사용할 수 없다. 부모 범위에서 사용할 수 없다.

<!DOCTYPE html> 
 
<html> 
 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> 
 
<body ng-app=""> 
 

 
    <input type="radio" ng-model="fileType" value="Excel" style=" margin-left: 19px;" >Excel 
 
    <input type="radio" ng-model="fileType" value="Text" style=" margin-left: 19px;" >Text 
 

 
    <div ng-switch="fileType"> 
 
    <div ng-switch-default="Excel"> 
 
     <h4 style="margin-top: 15px;"> 
 
     <b>Analysis Type </b> 
 
     <input type="radio" ng-model="AT" value="SRI" style=" margin-left: 8px;" >SRI 
 
     <input type="radio" ng-model="AT" value="JAG" style=" margin-left: 23px;" >JAG 
 
     </h4> 
 
     <!-- {{AT}} i am able to acess it --> 
 
    </div> 
 
    <div ng-switch-when="Text"> 
 
     <h4 style="margin-top: 15px;"></h4> 
 
    </div> 
 
    </div> 
 
    {{fileType}} \t 
 
    {{AT}} <!-- how can i access it --> 
 

 
</body> 
 
</html>

답변

0

이 자신의 범위를 만들기 때문에 ng-switch에 대한 범위를 상속 문제를주세요.

사용 ng-model="$parent.AT" 블록 ng-switch

<!DOCTYPE html> 
 
<html> 
 
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> 
 
<body ng-app=""> 
 

 
<input type="radio" ng-model="fileType" value="Excel" style=" margin-left: 19px;" >Excel 
 
<input type="radio" ng-model="fileType" value="Text" style=" margin-left: 19px;" >Text 
 

 
<div ng-switch="fileType"> 
 
      <div ng-switch-default="Excel"> 
 
\t \t <h4 style="margin-top: 15px;"><b>Analysis Type </b> 
 
\t \t \t <input type="radio" id="atype_sri" ng-model="$parent.AT" value="SRI" style=" margin-left: 8px;" ><label for="atype_sri">SRI</lable> 
 
\t \t \t <input type="radio" id="atype_jag" ng-model="$parent.AT" value="JAG" style=" margin-left: 23px;" ><label for="atype_jag">JAG</label></h4> 
 
      </div> 
 
      <div ng-switch-when="Text"> 
 
\t \t <h4 style="margin-top: 15px;"> \t \t  </h4> 
 
      </div> 
 
      </div> 
 
\t {{fileType}} \t 
 
    {{AT}} <!-- now you can access it --> 
 

 
</body> 
 
</html>

+0

다시 공급을 위해 대단히 감사합니다 –