Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i conditionally apply title in angular js

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' " 
like image 392
Prashobh Avatar asked Jun 04 '14 11:06

Prashobh


2 Answers

Just do this

<span title="{{ item.status ? 'create' : 'delete'}}" class="check-{{ item.status }}"></span> 
like image 149
TKrugg Avatar answered Sep 24 '22 01:09

TKrugg


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> 
like image 37
A. Figueroa Avatar answered Sep 22 '22 01:09

A. Figueroa