>  기사  >  백엔드 개발  >  각도

각도

WBOY
WBOY원래의
2016-09-28 08:38:251403검색

json을 통해 다중 레벨 선택을 생성했습니다

<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는 다음과 같습니다.

<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) {
                //    console.log(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를 통해 왜 얻을 수 없는지 모르겠습니다.

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.