Home >Backend Development >PHP Tutorial >angular of
I generated a multi-level select through 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 looks like this:
<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>
Activate news_submit by clicking the button. The desired effect is to output col_selectlv, but the output result is undefined.
ng-model is bound successfully, because the {{col_selectlv[1].colname}} marked above can be output, but I don’t know why it cannot be obtained through $scope.col_selectlv.