All Projects → MrHuxu → cn-city-select

MrHuxu / cn-city-select

Licence: other
🌆 A directive being used to provide China region selector for Angular app.

Programming Languages

HTML
75241 projects

Projects that are alternatives of or similar to cn-city-select

cityPicker
jQuery 城市模拟下拉插件
Stars: ✭ 26 (+36.84%)
Mutual labels:  city-select
citySelector
🛳基于mpvue的微信小程序 城市/区县定位选择模块 汉字/拼音搜索 可直接使用 已更新
Stars: ✭ 52 (+173.68%)
Mutual labels:  city-select

ChinaCitySelect

test

This is a plugin to make it easy to add a China region selector into your Angular app.

Install

Install this plugin by using bower.

# enter your asset directory
bower install angular cn-city-select --save

Usage

  1. First of all you should load Angularjs in your page, and then load this plugin.

     <!-- place this code into your page -->
     <script type="text/javascript" src='/xxx/angular.min.js'></script>
     <script type="text/javascript" src='/xxx/cn-city-select.min.js'></script>
     <script type='text/javascript' src='/xxx/yourJS.js'></script>
    
  2. Then create your own Angular module, controller and city-select div.

     <div ng-app='yourModule'>
     	<div city-select></div>
     </div>
    
  3. Import the module into your module, and then the plugin works!

     // place this code into yourJS.js
     angular.module('yourModule', ['cnCitySelect'])
    
  4. There are two attributes belong to directive.

    • select-result: This attribute will pass a name of variable and provide a data binding between the variable and select result.
    • select-class: This attribute will pass a string which will be assigned to the class attribute of each select element.

Sample

This is a small sample of this plugin.

<html>
<meta charset="UTF-8">
<style>
  .test-class {margin: 30px 0 0 30px; font-size: 30px}
</style>
<body>
  <div ng-app='testModule'>
    <div ng-controller='testCtrl'>
      <div select-result='result' select-class='test-class' city-select></div>
      <p>{{result}}</p>
    </div>
  </div>
</body>
<script src='./angular.min.js'></script>
<script src='./cn-city-select.min.js'></script>
<script>
  angular.module('testModule', ['cnCitySelect']).controller('testCtrl', function ($scope) {});
</script>
</html>

demo

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].