<div ng-controller="AjaxCtrl">
<h1>AJAX - Oriented</h1>
<div>
Country:
<select id="country" ng-model="country" ng-options="country for country in countries">
<option value=''>Select</option>
</select>
</div>
<div>
City: <select id="city" ng-disabled="!cities" ng-model="city" ng-options="city for city in cities"><option value=''>Select</option></select>
</div>
<div>
Suburb: <select id="suburb" ng-disabled="!suburbs" ng-model="suburb" ng-options="suburb for suburb in suburbs"><option value=''>Select</option></select>
</div>
</div>
<div ng-controller="StaticCtrl">
<h1>Static - Oriented</h1>
<p>This approach may be better when you have the entire dataset</p>
<div>
Country:
<select id="country" ng-model="cities" ng-options="country for (country, cities) in countries">
<option value=''>Select</option>
</select>
</div>
<div>
City: <select id="city" ng-disabled="!cities" ng-model="suburbs" ng-options="city for (city, suburbs) in cities"><option value=''>Select</option></select>
</div>
<div>
Suburb: <select id="suburb" ng-disabled="!suburbs" ng-model="suburb" ng-options="suburb for suburb in suburbs"><option value=''>Select</option></select>
</div>
</div>

js

function AjaxCtrl($scope) {
$scope.countries = ['usa', 'canada', 'mexico', 'france'];
$scope.$watch('country', function(newVal) {
if (newVal) $scope.cities = ['Los Angeles', 'San Francisco'];
});
$scope.$watch('city', function(newVal) {
if (newVal) $scope.suburbs = ['SOMA', 'Richmond', 'Sunset'];
});
} function StaticCtrl($scope) {
$scope.countries = {
'usa': {
'San Francisco': ['SOMA', 'Richmond', 'Sunset'],
'Los Angeles': ['Burbank', 'Hollywood']
},
'canada': {
'People dont live here': ['igloo', 'cave']
}
};
}

最新文章

  1. nginx.conf配置(支持thinkphp)
  2. Ubuntu 下apache2开启rewrite隐藏index.php
  3. php Windows系统 wamp集成环境下redis的使用
  4. performSelector may cause a leak because its selector is unknown解决
  5. 初始zookeeper与集群搭建实例
  6. Target runtime com.genuitec.runtime.generic.jee50 is not defined
  7. 深入PHP内核之in_array
  8. ios7适配一些问题以及64位32位
  9. SQL Server 日志收缩
  10. 数据库中间件 Sharding-JDBC 源码分析 —— SQL 解析(三)之查询SQL
  11. Spring详解(五)------AspectJ 实现AOP
  12. 在Vue.js2.0中组件模板子元素数量问题
  13. Reflection的getCallerClass静态方法
  14. Jenkins 随笔
  15. JAVA编程思想的理解
  16. fetch数据请求的封装
  17. C语言基础一(敲打键盘、寻找资料)
  18. Linux基础命令---lp打印文件
  19. VSTO:使用C#开发Excel、Word【16】
  20. 《Linux内核设计与实现》第4章读书整理

热门文章

  1. composer安装自己的包
  2. sort 排序详解
  3. easyui-datagrid加载时的效率低下,解决方案
  4. Servlet详解
  5. IntelliJ IDEA 部署远程服务
  6. 下载google play上的APP
  7. git分支--branch
  8. hdu_2110_Crisis of HDU(母函数)
  9. 初识golang
  10. iOS 上架提示ipad需要显示四个方位,而我们只能竖屏的时候的解决办法