ng-disable不使用ng-option

时间:2016-03-14 14:39:16

标签: javascript angularjs angularjs-ng-options angularjs-ng-disabled

这只发生在我使用指令

模板:(userlist.html)

<select id="teamUsers" ng-model="selectedUser.selected" data-placeholder="Select User" chosen="" class="chosen-select input-md"
        ng-options="user.ID as user.FirstName+' '+user.LastName+', '+user.Team.Name for user in teamUsers"
        ng-disabled="accessDisabled()">
    <option disabled></option>
</select>

指令:

    App.directive('selectUser', function () {
        return {
            restrict: 'E',
            templateUrl: 'userlist.html',
            controller: ['$scope', '$timeout', '$http', '$rootScope', function ($scope, $timeout, $http, $rootScope) {
                $scope.teamUsers = {
                              ID:1,
                              FirstName:'John',
                              LastName:'Doe',
                              Team:{
                                      Name : 'Web Team'
                                    }
                };
                $scope.accessDisabled = function () {
                    return !$rootScope.HasPermission('ChangeUserControl', 'Control'); // checking permission with return true and false.
                }
                $timeout(function () {
                    //$scope.teamUsers http request basically
                });
            }]

        };
    });

在视图中使用:

<select-user></select-user>

一切都运行得很好,我不知道为什么ng-disable错过了我的senerio下拉列表中的行为并没有禁用

0 个答案:

没有答案