angularjsasp.net-mvcangularjs-ng-disabled

angularjs ng-disabled with MVC Model and angular scoped model


I want to use a combination of my angular model and MVC model to disable an anchor tag (Model.Technician is a bool):

<a href="#" title="" class="btn btn-default" ng-disabled="selectedTasksCount <= 0 || '@Model.Technician' == 'true'" >Click here</a>

I ended up having to do this:

<a href="#" title="" class="btn btn-default" ng-disabled="selectedTasksCount <= 0 || '@Model.Technician' == 'ng-disabled'" >Click here</a>

... because Model.Technicain always seems to render as 'ng-disabled'. What am I doing wrong or is there a better way?


Solution

  • Instead of writing a tonn of conditions into ng-disables it would be better to write a function into controller which return boolean result.