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

angular.js - 使用angular如何實(shí)現(xiàn)讓checkbox單選,只能選擇一個(gè)呢?
習(xí)慣沉默
習(xí)慣沉默 2017-05-15 17:03:18
0
2
686

使用angular如何實(shí)現(xiàn)讓checkbox單選,只能選擇一個(gè)呢?

如圖,以下是table中的checkbox選項(xiàng):

<td width="30" style="text-align: left"><input
                            type="checkbox" ng-model="checkboxes.items[item.bookingId]" name="flag" ng-click="updateSelection(item.bookingId,checkboxes.items)"/></td>

如果在對象的controller里面實(shí)現(xiàn),只能讓其單選,選擇一個(gè)呢??

習(xí)慣沉默
習(xí)慣沉默

全部回復(fù)(2)
迷茫

checkbox是復(fù)選框,單選請用radio

Ty80

試試這個(gè)呢

<p ng-controller="MyCtrl">
    <p ng-repeat="item in list">
        <label><input type="checkbox" ng-model="item.checked" ng-change="onChange(item)">{{item.name}}</label>
    </p>
</p>
.controller('MyCtrl', function ($scope) {
    $scope.selected = '';
    $scope.list = [
        {id: 1, name: 'xxx'},
        {id: 2, name: 'yyy'},
        {id: 3, name: 'zzz'}
    ];

    $scope.onChange = function (item) {
        if (item.checked) {
            if (!$scope.selected) $scope.selected = item;
            if ($scope.selected !== item) item.checked = false;
        } else {
            $scope.selected = '';
        }
    }
});
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板