Angular.js用法(四):制作省市联动菜单

来源:互联网 发布:淘宝上卖什么比较好 编辑:程序博客网 时间:2024/05/16 16:40
<html>  <head><meta charset="utf-8">    <script src="https://cdn.bootcss.com/angular.js/1.5.8/angular.min.js"></script></head><body><h1>angular联动菜单</h1><form action="" ng-app="liandong" ng-controller="contro"><select name="" id="" ng-model='pid' ng-change="shi()">    <option value="{{$index}}" ng-repeat="pro in pros">{{pro}}</option></select><select name="" id="" ng-model='pid' ng-change="shi()">    <option value="{{$index}}" ng-repeat="city in citys">{{city}}</option></select></form><script>    var app = angular.module('liandong',[]);    app.controller('contro',function($scope){        var maps = [            ['朝阳','海淀','昌平'],            ['嘉定','浦东','青浦'],        ];        $scope.pros=['北京','上海'];        $scope.shi=function(){            $scope.citys=maps[this.pid];           }    });</script></body></html>
原创粉丝点击