1. <!DOCTYPE html>
    2. <html>
    3. <head>
    4. <meta charset="utf-8">
    5. <script src="https://cdn.bootcss.com/angular.js/1.4.6/angular.min.js"></script>
    6. </head>
    7. <body>
    8. <div ng-app="myApp" ng-controller="myCtrl">
    9. <p>选择网站:</p>
    10. <input type="checkbox" ng-model="myVar1" name="name" ng-change=checkBoxfn()>苹果
    11. <input type="checkbox" ng-model="myVar2" name="name" ng-change=checkBoxfn()>
    12. <input type="radio" ng-model="myVar" value="dogs1">Dogs
    13. <input type="radio" ng-model="myVar" value="dogs">Dogs
    14. <select ng-model="selectedSite" ng-options="x.url for x in sites" ng-change=fn()>
    15. <option disabled value="">请选择数据源类型</option>
    16. </select>
    17. <h1>你选择的是: {{selectedSite.site}}</h1>
    18. <p>网址为: {{selectedSite.url}}</p>
    19. </div>
    20. <script>
    21. var app = angular.module('myApp', []);
    22. app.controller('myCtrl', function($scope) {
    23. $scope.sites = [
    24. {site : "Google", url : "http://www.google.com"},
    25. {site : "Runoob", url : "http://www.runoob.com"},
    26. {site : "Taobao", url : "http://www.taobao.com"}
    27. ];
    28. $scope.fn=function(){
    29. console.log(this)
    30. }
    31. });
    32. </script>
    33. <p>该实例演示了使用 ng-options 指令来创建下拉列表,选中的值是一个对象。</p>
    34. </body>
    35. </html>