The version of Angular.js is 1.2.5
The function to be implemented is Select three-level linkage.
The problem that arises is: after selecting the second level (country), the third level (city) does not appear.
Please guide me heroes!
<p ng-app="app" ng-controller="global"> <select ng-model="ihg" ng-options="ihg.text for ihg in g"> <option value="">-- 洲際 --</option> </select> <select ng-if="ihg.nat" ng-model="nat" ng-options="nat.text for nat in ihg.nat"> <option value="">-- 國(guó)家 --</option> </select> <select ng-if="nat.cities" ng-model="city" ng-options="city.text for city in nat.cities"> <option value="">-- 城市 --</option> </select> </p>
var app=angular.module("app",[]); app.controller("global",['$scope',function($scope){ $scope.g=[ {text:"亞洲",nat:[ {text:"中國(guó)",cities:[{text:"北京"}]}, {text:"巴林",cities:[]}, {text:"韓國(guó)",cities:[{text:"首爾"}]}, {text:"黎巴嫩",cities:[]}, {text:"東帝汶",cities:[]}, {text:"尼泊爾",cities:[]}, {text:"泰國(guó)",cities:[{text:"曼谷"}]}, {text:"巴基斯坦",cities:[{text:"伊斯蘭堡"}]} ]}, {text:"歐洲",nat:[ {text:"德國(guó)",cities:[]}, {text:"英國(guó)",cities:[]} ]}, {text:"北美洲"}, {text:"南美洲"}, {text:"非洲"}, {text:"大洋洲"}, {text:"南極洲"} ] }]);
人生最曼妙的風(fēng)景,竟是內(nèi)心的淡定與從容!