I am very new to Angularjs. I want to set a value for title attribute, based on a boolean variable.
Sample code attached here.
<tr ng-repeat="doc in $data" ng-class="{{doc.is_today}} ? 'highlight' : ''"
ng-attr-title="({{doc.is_today}}) ? 'Today' : ''">
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
Thanks,
Remove {{}} in condition
<tr ng-repeat="doc in $data" ng-class="doc.is_today ? 'highlight' : ''"
ng-attr-title="doc.is_today ? 'Today' : ''">
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
Only use {{}} if you want to print the value.
Alternatively you can do the following also
<tr ng-repeat="doc in $data" ng-class="{{doc.is_today ? 'highlight' : ''}}"
ng-attr-title="{{doc.is_today ? 'Today' : ''}}">
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
Link to fiddle
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