首页  >  文章  >  后端开发  >  angular ng

angular ng

WBOY
WBOY原创
2016-09-28 08:38:251436浏览

我通过json生成了多级select

<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>

通过点击button激活news_submit,希望的效果是能输出col_selectlv,但是输出的结果是未定义。
ng-model是绑定成功了,因为上面标注的那个{{col_selectlv[1].colname}}是可以输出的,但是不知道为什么就是不能通过$scope.col_selectlv获取。

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn