Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happened to ng-title directive in Angular 2?

Tags:

angular

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"?

like image 846
Carcamano Avatar asked Sep 16 '16 15:09

Carcamano


People also ask

Which of the following is correct about angular 2 directive?

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.

What is Ng ATTR title?

ng-attr-title adds tooltip to element.

Which directive definition option is used to replace the current element if true?

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.

What are the different directives in Angular?

The three types of directives in Angular are attribute directives, structural directives, and components.


1 Answers

You could use:

<div [attr.title]="item.favourite ? 'Remove' : 'Add'">

That will bind to the title attribute to your expression.

like image 60
WiredPrairie Avatar answered Oct 03 '22 04:10

WiredPrairie