我是HTML

angularJs(2)表单中下拉框单选多选

  1. 多选

    <input type="checkbox" ng-model='game' ng-true-value="1" ng-false-value="0"/>游戏
    <input type="checkbox" ng-model="video" ng-true-value="1" ng-false-value="0"/>电影
    

     

  2. 单选

    <input type="radio" ng-model="sex" value="1" />
    <input type="radio" ng-model="sex" value="0" />
    

      

  3. 下拉框
    $scope.citys=$scope.data[0].city; 解决第一个选项为空白

    <!DOCTYPE html>
    <html>
    <head lang="en">
        <meta charset="UTF-8">
        <title></title>
        <style>
            .ng-cloak{
                display: none;
            }
        </style>
    </head>
    
    <body ng-app="app" ng-controller="ctr" ng-cloak class="ng-cloak">
    
    <select  ng-model="citys">
    
        <option ng-repeat="item in data">{{item.city}}</option>
    </select>
    <p>{{citys}}</p>
    <script src="../angular.js"></script>
    <script>
        angular.module('app',[])
                .controller('ctr',function($scope){
                 $scope.data=[
                     {
                         city:'北京',
                         code:541654
                     },
                     {
                         city:'上海',
                         code:5756
                     },
                     {
                         city:'广州',
                         code:54454
                     }
                 ];
                    $scope.citys=$scope.data[0].city;
    
    
                })
    </script>
    
    </body>
    </html>
    

      

     

posted @ 2017-04-21 20:20  你值得拥有xxx  阅读(3084)  评论(0编辑  收藏  举报