How can I conditionally apply title in angular.js
<span title=" Create " class="check-{{ item.status }}"></span>
If status equals to true, then I want to show title as Create else Delete.
For class I can apply conditions like
ng-class="{true: 'active'}[isActive]
and in controller
$scope.isActive = true;
or
$scope.isActive = false;
How can I do the same in title?
I tried something like:
title = " item.status = true | 'create' "
Just do this
<span title="{{ item.status ? 'create' : 'delete'}}" class="check-{{ item.status }}"></span>
To avoid directly binding to HTML Element properties, you can use the following:
<span [attr.title]="item.status ? 'create' : 'delete'" [ngClass]="'check-' + item.status"></span>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With