angular三级联动

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.proList = [{
"amode": "河南",
"citys": [{
"name": "郑州",
"area": [{
"aname": "郑1区"
}, {
"aname": "郑2区"
}]
},
{
"name": "开封",
"area": [{
"aname": "开1区"
}, {
"aname": "开2区"
}]
}
]
},
{
"amode": "河北",
"citys": [{
"name": "石家庄",
"area": [{
"aname": "石1区"
}, {
"aname": "石2区"
}]
},
{
"name": "邯郸",
"area": [{
"aname": "邯1区"
}, {
"aname": "邯2区"
}]
}
]
}
];
$scope.proChange = function() {
$scope.select2 = $scope.select1.citys[0];
$scope.select3 = $scope.select2.area[0];
}
$scope.cityChange = function() {
$scope.select3 = $scope.select2.area[0];
}
});
</script>
</head>


<body ng-app="myApp" ng-controller="myCtrl">
<div>
<select style="width: 120px;" ng-init="select1=proList[0]" ng-model="select1" ng-change="proChange();" ng-options="item.amode for item in proList"></select>
<select style="width: 120px;" ng-init="select2=select1.citys[0]" ng-change="cityChange();" ng-model="select2" ng-options="data1.name for data1 in select1.citys"></select>
<select style="width: 120px;" ng-init="select3=select2.area[0]" ng-model="select3" ng-options="a.aname for a in select2.area"></select>
</div>
</body>


</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值