There is a span tag with glyphicon icon that I want to disable.But ng-disabled is not working, that is the icon is still clickable.
<span ng-disabled="true" class="glyphicon glyphicon-trash" style="font-size:13px;" aria-hidden="true" ng-click="DeleteIpAdress(objIpAdress)" ng-show="objIpAdress.ShowRemoveButton" ng-model="objIpAdress.ShowRemoveButton" title="Delete IP address"></span>
Is anything wrong in the tag?
There is a span tag with glyphicon icon that I want to disable.But ng-disabled is not working, that is the icon is still clickable.
<span ng-disabled="true" class="glyphicon glyphicon-trash" style="font-size:13px;" aria-hidden="true" ng-click="DeleteIpAdress(objIpAdress)" ng-show="objIpAdress.ShowRemoveButton" ng-model="objIpAdress.ShowRemoveButton" title="Delete IP address"></span>
Is anything wrong in the tag?
Share Improve this question asked Nov 17, 2015 at 7:46 Code GuruCode Guru 15.6k30 gold badges143 silver badges210 bronze badges 6 | Show 1 more comment4 Answers
Reset to default 9ng-disabled
directive works only with input fields and buttons. It does not work with span. Ref: ngDisabled Documentation
You can prevent click action using following code
ng-click="isClickAllowed && DeleteIpAdress(objIpAdress)"
ng-disabled doesn't work on span.So I disabled the click
ng-click="disabledConditionHere || DeleteIpAdress(objIpAdress)"
and then changed the style of span by using class
.disable-span{
color: #E6E6E6;
cursor: not-allowed;
}
and used class in span tag
class="disable-span"
I had this same problem once, from memory the solution is to put the disabled condition in the ng-click.
ng-click="disabledConditionHere || DeleteIpAdress(objIpAdress)"
if you are using bootstrap add bootstrap class btn btn-xs
to the span
tag. This will fix ng-disabled
for span tag. Works in firefox.
true
in scope, it will be the real true. – Qwertiy Commented Nov 17, 2015 at 7:53