1👍
✅
You are running into issue where you need to let ng-repeat
complete it’s digest before trying to manipulate the element html. There are several ways to do it, using attrs.$observe
or $timeout
.
Baasically what is happening is your code is firing before the element is rendered
For no more than what you are doing you could simply use ng-class
and you won’t need a directive
<table ng-table="tableParams" class="table">
<tr ng-repeat="propertyObject in $data">
<td data-title="'Name'" sortable="'name'">
[[ userObject.name ]]
</td>
<td>
<i class='fa fa-times fa-lg'
ng-class="{'text-danger':!userObject.active,'text-success':userObject.active}">
</i>
</td>
</tr>
</table>
Or you could really simplify the directive to only return the <i>
as template
using the ng-class
Source:stackexchange.com