내 응용 프로그램 페이지에 매우 큰 폼이 있으며 JSON
변수가 있습니다. 여기서 모든 폼 데이터를 저장하고 controllerAs
식을 사용하고 있습니다.Angular에서 HTML 블록의 범위를 정의하는 방법은 무엇입니까?
<form>
<input type="text" data-ng-model="ctrl.myJSON.name"/>
<input type="text" data-ng-model="ctrl.myJSON.old"/>
<input type="text" data-ng-model="ctrl.myJSON.address"/>
<input type="text" data-ng-model="ctrl.myJSON.email"/>
<input type="text" data-ng-model="ctrl.myJSON.phone"/>
<!-- and many more... -->
</form>
방법에 내가 필요없이 모든 분야에서이 변수 많은 시간을 반복, 양식 범위로 myJSON
를 정의 할 수 있습니다?
나는 어쩌면이 방법 더러운 범위 및 HTML 블록 – Lai32290
의 다른 부분에 오버 플로우 생각 승 음, JSON의 내용이 바뀌면 다소 침입 적입니다. angle.extend (this, myJSON) 또는 제한된 속성을 확장 할 수 있습니다. angular.extend ($ scope, {name : myJSON.name, old : myJSON.old}) –