Angularjs 省市区级联


Json 地区文件:http://blog.csdn.net/youshi520000/article/details/70808580

angularjs

angular.module('app')
    .controller('inbillofladingCtrl', ['$scope', '$filter', '$location', 'alertify', 'transferService', 'pagerService','inbillofladingService',
        function ($scope, $filter, $location, alertify, transferService, pagerService, inbillofladingService) {
            $scope.chinaCities = CityAreaList;
            //省份切换
            $scope.changeProvince = function () {
                var province = $scope.searcher.ShipAddressProvince;
                if (!angular.equals("", province)) {
                    $scope.CityList = $scope.chinaCities.find(c => c.name === province).city;
                } else {
                    $scope.CityList = null;
                    $scope.AreaList = null;
                }
            }
            //城市切换
            $scope.changeCity = function () {
                var city = $scope.searcher.ShipAddressCity;
                if (!angular.equals("", city)) {
                    $scope.AreaList = $scope.CityList.find(c=>c.name===city).area;
                } else {
                    $scope.AreaList = null;
                }
            }
        }]);

 

html

 选择省:
            <select ng-model="searcher.ShipAddressProvince" ng-change="changeProvince()">
                <option value="">请选择</option>
                <option ng-repeat="v in chinaCities" value="{{v.name}}">{{v.name}}</option>
            </select>
            选择市:
            <select ng-model="searcher.ShipAddressCity" ng-change="changeCity()">
                <option value="">请选择</option>
                <option ng-repeat="v in CityList" value="{{v.name}}">{{v.name}}</option>
            </select>
            选择区:
            <select ng-model="searcher.ShipAddressArea">
                <option value="">请选择</option>
                <option ng-repeat="v in AreaList" value="{{v}}">{{v}}</option>
            </select>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM