国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

angular.js中一組復選框,怎么實現(xiàn)選中其中一個,其他不能選?
大家講道理
大家講道理 2017-05-15 17:04:00
0
3
777

angular.js中一組復選框,怎么實現(xiàn)選中其中一個,其他不能選?

大家講道理
大家講道理

光陰似箭催人老,日月如移越少年。

全部回復(3)
伊謝爾倫

雷雷

洪濤

ng-model需要一致。用value控制內容.

<script>
  angular.module('radioExample', [])
    .controller('ExampleController', ['$scope', function($scope) {
      $scope.color = {
        name: 'blue'
      };
      $scope.specialValue = {
        "id": "12345",
        "value": "green"
      };
    }]);
</script>
<form name="myForm" ng-controller="ExampleController">
  <label>
    <input type="radio" ng-model="color.name" value="red">
    Red
  </label><br/>
  <label>
    <input type="radio" ng-model="color.name" ng-value="specialValue">
    Green
  </label><br/>
  <label>
    <input type="radio" ng-model="color.name" value="blue">
    Blue
  </label><br/>
  <tt>color = {{color.name | json}}</tt><br/>
 </form>
 Note that `ng-value="specialValue"` sets radio item's value to be the value of `$scope.specialValue`.
大家講道理

以下代碼就是個思路,有很多問題,比如我發(fā)現(xiàn)的,列表不能抽取出來,用ng-for不可行。.disabled需要自己去調節(jié)樣式。


<!DOCTYPE html>
<html lang="en" ng-app="app">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link  rel="stylesheet">
</head>
<body>
    <p ng-controller="demo">
        <p>當前值: {{hobby}}</p>
        <ul>
            <li>
                <label>吃:</label>
                <input type="checkbox" ng-true-value="1" ng-model="hobby" ng-class="{disabled: hobby}" ng-change="handleCheckbox($event)" />
            </li>
            <li>
                <label>睡:</label>
                <input type="checkbox" ng-true-value="2" ng-model="hobby" ng-class="{disabled: hobby}" ng-change="handleCheckbox($event)" />
            </li>
        </ul>
    </p>

    <script src="http://cdn.bootcss.com/angular.js/1.5.7/angular.min.js"></script>
    <script>
        angular.module('app', [])
            .controller('demo', ['$scope', function ($scope) {
                $scope.hobby = false;
            }]);


    </script>
</body>
</html>
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板