Answer the question
In order to leave comments, you need to log in
How to calculate and store a local variable in ng-repeat angular?
Hello.
There is the usual familiar ng-repeat of the form:
<div ng-repeat="(position, task) in Tasks.plannedTasks">
{{(task.plan - (TasksTimeSpent[task.id][task.worker]).toFixed(2)}}
</div>
{{(task.plan - (TasksTimeSpent[task.id][task.worker]).toFixed(2)}}
< 0 - tint the block in red Answer the question
In order to leave comments, you need to log in
Solved the problem like this:
<div
ng-init="curDif=(task.scrum_task_final_plan - (TasksTimeSpent[task.scrum_task_pf_task_id][task.scrum_task_worker] || 0)).toFixed(2)"
>
{{curDif}}
<div ng-if="isOverdue(curDif)">
<i class="fa fa-exclamation-triangle text-red" aria-hidden="true"></i>
</div>
</div>
The correct way out of the situation is to process tasks when they hit the controller, and not when they are output.
When outputting, you should have the code:
<div ng-repeat="(position, task) in Tasks.plannedTasks" ng-class="{'is-overdue': task.isOverdue}">
{{(task.plan - (TasksTimeSpent[task.id][task.worker]).toFixed(2)}}
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question