Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How call a function in ng-repeat [duplicate]

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>
like image 540
Mishu Lojan Avatar asked Dec 28 '25 07:12

Mishu Lojan


1 Answers

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 '';
}
like image 78
Dan Wilson Avatar answered Dec 30 '25 19:12

Dan Wilson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!