zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    mac 程序 Access-JSON-Data
    第一个 mac 程序 Create-JSON-Model
    CATransform3D的m34使用
    超级好用的解析JSON数据的网站
    iOS设计模式
    iOS设计模式
    iOS设计模式
    iOS设计模式
    iOS设计模式
    iOS设计模式
  • 原文地址:https://www.cnblogs.com/ideacore/p/7685165.html
Copyright © 2011-2022 走看看