Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I have a list of checkboxes on view page for to send notifications for different roles.I want to disable some checkboxes in unchecked state initially.

I am working with following code in view

<div ng-repeat="notification in NotificationList  | filter:{Media: item.Media}" ng-if="!collapsedNotification" ng-class="{'pad-top-4':($first)}" >
                                    <label for="NotificationLabel" class="col-sm-4 col-md-4 col-lg-4 control-label font-normal" title="{{notification.NotificationLabel}}">{{notification.NotificationLabel}}</label>
                            <div class="col-sm-1 col-md-1 col-lg-1"  style="line-height:35px;">
                                <span  class="col-lg-2 col-md-2 col-sm-2 item-padding ">
                                    <span class="default-pointer" ng-checkbox  ng-init="ToAdmin=false" ng-model='ToAdmin' ng-click="disableClick()" ng-disabled="ToAdmin"></input>

                                </span>

                            </div>
                            <div class="col-sm-1 col-md-1 col-lg-1" style="line-height:35px;">
                                <span  class="col-lg-2 col-md-2 col-sm-2 item-padding ">
                                    <span class="default-pointer" ng-checkbox ng-model='notification.ToNutritionist'></span>                                        
                                </span>
                            </div>
                            <div class="col-sm-1 col-md-1 col-lg-1"  style="line-height:35px;">
                                <span  class="col-lg-2 col-md-2 col-sm-2 item-padding ">
                                    <span class="default-pointer"  ng-checkbox ng-model='notification.ToPatient'></span>                                        
                                </span>
                            </div>
                                   </div>

How can i disable the checkboxes(in unchecked state) for specific roles in controller using angularjs?

share|improve this question

You can use the ng-disabled property.

Like this example :

<input type="checkbox" ng-click="disable=!disable">

<input type="checkbox" ng-disabled="disable">
share|improve this answer
    
As @alexis said you can use ng-disabled property. Implementation depends on the scenario in your application <input type="checkbox" ng-disabled="expression"> // This is a method of implementation If the expression is truthy, then the disabled attribute will be set on the element – Jobins John Jul 30 '15 at 10:19
    
yes. I have already worked with it but it is not working. <span class="default-pointer" ng-checkbox ng-init="ToAdmin=false" ng-model='ToAdmin' ng-click="disableClick()" ng-disabled="ToAdmin"></input> – Neha Jul 30 '15 at 10:30
    
Don't use <span ng-checkbox> then and use <span><input type="checkbox" ng-disable="expression"></span> – Alexis Jul 30 '15 at 12:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.