Angular.js 的版本是1.2.5
要实现的功能是 Select 三级联动。
出现的问题是:选择完第二级(国家)的时候,第三级(城市)没有出现。
请大侠们指导!
<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="">-- 国家 --</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:"中国",cities:[{text:"北京"}]},
{text:"巴林",cities:[]},
{text:"韩国",cities:[{text:"首尔"}]},
{text:"黎巴嫩",cities:[]},
{text:"东帝汶",cities:[]},
{text:"尼泊尔",cities:[]},
{text:"泰国",cities:[{text:"曼谷"}]},
{text:"巴基斯坦",cities:[{text:"伊斯兰堡"}]}
]},
{text:"欧洲",nat:[
{text:"德国",cities:[]},
{text:"英国",cities:[]}
]},
{text:"北美洲"},
{text:"南美洲"},
{text:"非洲"},
{text:"大洋洲"},
{text:"南极洲"}
]
}]);
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
ng-if改为ng-show