3

I want to disable the angular select dropdown. Actually I want restrict the access for few users. Code link:http://plnkr.co/edit/mGnpQynWKkRLBC0VEHBR?p=preview

1 Answer 1

6

In controller add:

$scope.isDisabled = false; // change to true to disable the multiselect

Then, the view should be (look at the disabled attribute):

<multiselect class="input-xlarge" multiple="true"
    ng-model="selectedCar"
    options="c.name for c in cars"
    change="selected()" disabled="isDisabled"></multiselect>

Finally, add the proper logic to set the $scope.isDisabled in your controller.

Sign up to request clarification or add additional context in comments.

8 Comments

HI Thanks for your suggestion, But i tried the same above solution but wont work it for me may be i put the controller not proper place. can you tell where i have to add controller in the bellow code >>>>>>>>>>>>>>> var app = angular.module('plunker', ['ui.multiselect']); app.controller('MainCtrl', function($scope) { $scope.name = 'World'; $scope.cars = [{id:1, name: 'Audi'}, {id:2, name: 'BMW'}, {id:1, name: 'Honda'}]; $scope.selectedCar = []; $scope.fruits = [{id: 1, name: 'Apple'}, {id: 2, name: 'Orange'},{id: 3, name: 'Banana'}]; $scope.selectedFruit = null; });
Please, reread my answer. I just forked your plnkr that include my modifications: plnkr.co/edit/oWPIPH5XVPI7UNZsB2Gz?p=preview
but as you can also see the output in plunkr it's not working. It should be disabled right
change $scope.isDisabled to true in your controller and it will be disabled
Hi i have one more question. Actually this mainly i have to used for this logic when the admin is opened all fields will be accessible. when other users access i want disable for specific users can you give any solution for this
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.