0

这仅在我使用指令时发生

模板:(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 下拉列表中的行为未禁用

4

0 回答 0