Hello I want to be able to calculate some numbers inside a controller that contains elements. This is what have tried (ionic APP too btw) :
.controller('tasksCtrl', function($scope) {
$scope.tasksCollection = [
{ info: 'Go studying', measured: 'no', total: 1, done: 1, id: 1 },
{ info: 'Go to the beach', measured: 'no', total: 1, done: 1, id: 2},
{ info: 'Run', measured: 'yes', total: 30, done: 15, id: 3}
];
$scope.calculateProductivity = function(){
var total = 0;
for(var i = 0; i < $scope.tasksCollection.length; i++){
var product = $scope.tasksCollection[i];
total += (tasksCollection.done / tasksCollection.total);
}
return total;
};
})
and the page has:
<div class="item tabs tabs-secondary tabs-icon-left">
<div ng-app="starter" ng-controller="tasksCtrl" class="tab-item tab-main-left">
<span class="title-red"> {{ calculateProductivity() }} </span><span class="medium-text">Productivity Ratio</span>
</div>
<div class="tab-item tab-main-right">
<span class="title-red">20 </span><span class="medium-text">PMoney</span>
</div>
</div>
On the output I only see "{{ calculateProductivity() }}" and not the result, but if I write tasksCollection.info it gets correctly displayed. thanks!