Mishu Lojan Mishu Lojan - 25 days ago 6
AngularJS Question

How call a function in ng-repeat

I try execute a function at the same time of ng-repeat to be able use the index of the repeat itself. But in this moment only execute the last time.

<div ng-repeat="i in arraysemanas" ng-init="add_days($index)">
<a class="item item-icon-left fecha" href="#">
<i class="icon calendar"></i>
<p class="date_c">{{CurrentDate_1| date:' EEEE dd MMMM'}}</p>
</a>
</div>

Answer

In your template:

<div ng-repeat="i in arraysemanas">
    <a class="item item-icon-left fecha" href="#">
        <i class="icon calendar"></i>
        <p class="date_c">{{CurrentDate_1|  date:' EEEE dd MMMM'}}</p>
        {{ add_days($index) }}
    </a>
</div>

In your controller:

add_days(index) {
    days += index; // or whatever you need to do
    return '';
}