0

I have an angular DropDown , which is bound to scope variable, which is array. I would like disable the dropdown when the array empty.

HTML

 <select class="qtDropDown" ng-model="chartModel" ng-options="riskimp.IndustryName for riskimp in riskImprovement"  ng-change="buildChartData(chartModel)"></select>

JS

if( $scope.riskProfileModel.riskProfileData.RiskImprovment ) 
 {

     //I am doing some chart generation
   }

  else  {

          return null;
       }

I am not sure how to disable the drop down. Can anybody suggest how to do that ?

2 Answers 2

1

If you can set a controller property in javascript return a bool if it is enabled/disabled then you can do the following:

<select ng-disabled="isDisabled">
    ...
</select>
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @Varedis. I am not sure who down voted for u answer, but it totally works the way I wanted it to.
On reflection you probably don't want to use that as advertised here: docs.angularjs.org/api/ng/directive/ngDisabled changing the code sample to ng-disabled="isDisabled" should perform the same though
1

Use the ng-disabled property to still show the object without hiding it. Add in your element:

ng-disabled="chartModel.length == 0"

Comments

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.