使用angular实现二级联动

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="../libs/angular.min.js"></script>
<script>
var app = angular.module("myApp",[]);
app.controller("myControl",function($scope,$http){
$scope.provinces = [
{
"pro": "北京",
"children": ["西二旗", "上地"]
},
{
"pro": "河北",
"children": ["石家庄", "邯郸"]
}
];

                            //请求外部json

                            /*

$http.get("provinces.json").then(function(res){
$scope.provinces =res.data;
});

                            */

});
</script>
</head>

<body ng-app="myApp" ng-controller="myControl" >
省份:<select ng-options=" p.pro for p in provinces" ng-model="s1">

</select>
城市:<select ng-options="c for c in s1.children" ng-model="s2">

</select>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/Do_the_best_/article/details/80359417