json을 통해 다중 레벨 선택을 생성했습니다
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | <code><div ng-app= "xx" ng-controller= "eee" >
<div>
**{{col_selectlv[1].colname}}**
<select ng-model= "col_selectlv[0]" ng-options= "x.colname for x in col_select[0]" required>
<option></option>
</select>
<select ng-model= "col_selectlv[1]" ng-options= "x.colname for x in col_selectlv[0].children"
ng- if = "col_selectlv[0].children"
required >
<option></option>
</select>
<select ng-model= "col_selectlv[2]" ng-options= "x.colname for x in col_selectlv[1].children"
ng- if = "col_selectlv[1].children" required >
<option></option>
</select>
<select ng-model= "col_selectlv[3]" ng-options= "x.colname for x in col_selectlv[2].children"
ng- if = "col_selectlv[2].children" required >
<option></option>
</select>
</div>
</div></code>
|
로그인 후 복사
app.js는 다음과 같습니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <code> app.controller( 'newseditor' , function ( $scope , $http , $routeParams ) {
$scope .newsid= $routeParams .id? $routeParams .id: '0' ;
$http ({
method: 'GET' ,
url: 'datacon/col_select.php' ,
}).success( function (response) {
if (response)
$scope .col_select = response;
})
$scope .change_selecter = function (r) {
$scope .select_range = r;
}
$scope .news_submit = function () {
console.log( $scope .col_selectlv)
}
});</code>
|
로그인 후 복사
버튼을 클릭하여 news_submit을 활성화합니다. 원하는 효과는 col_selectlv를 출력하는 것이지만 출력 결과는 정의되지 않습니다.
위에 표시된 {{col_selectlv[1].colname}}이 출력 가능하므로 ng-model은 성공적으로 바인딩되었으나 $scope.col_selectlv를 통해 왜 얻을 수 없는지 모르겠습니다.