我通過json產生了多級select
**{{col_selectlv[1].colname}}**//這個地方下文說到!
app.js是這樣的:
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) } });
通過點擊button啟用news_submit,希望的效果是能輸出col_selectlv,但是輸出的結果是未定義。
ng-model是綁定成功了,因為上面標註的那個{{col_selectlv[1].colname}}是可以輸出的,但是不知道為什麼就是不能通過$scope.col_selectlv擷取。
回複內容:
我通過json產生了多級select
**{{col_selectlv[1].colname}}**//這個地方下文說到!
app.js是這樣的:
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) } });
通過點擊button啟用news_submit,希望的效果是能輸出col_selectlv,但是輸出的結果是未定義。
ng-model是綁定成功了,因為上面標註的那個{{col_selectlv[1].colname}}是可以輸出的,但是不知道為什麼就是不能通過$scope.col_selectlv擷取。
你的控制器名字是eee還是newseditor,代碼好像不完整
原來是因為ng-if會建立一個子域,所以
app.controller('newseditor', function ($scope, $http,$routeParams) {
**$scope.col_selectlv={}** $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) }
}); 要定義一個$scope.col_selectlv,才能夠擷取到col_selectlv