I had this code in Angular 1:
<div ng-title="item.favourite ? 'Remove' : 'Add'">
<i class="someClass"> </i>
</div>
Angular 2 doesn't have a [ngTitle]
and I didn't find anything related in the docs.
Should I use title="{{item.favourite ? 'Remove' : 'Add'}}"
or is there an "Angular 2 way"?
Q 12 - Which of the following is correct about Angular 2 Directive? A - A directive is a custom HTML element that is used to extend the power of HTML.
ng-attr-title adds tooltip to element.
As the documentation states, 'replace' determines whether the current element is replaced by the directive. The other option is whether it is just added to as a child basically.
The three types of directives in Angular are attribute directives, structural directives, and components.
You could use:
<div [attr.title]="item.favourite ? 'Remove' : 'Add'">
That will bind to the title
attribute to your expression.
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