Calling function without using ng-click inside ng-repeat- AngularJS

Problem

I have following code:

<div ng-repeat="dateDetails in visitsDates | orderBy : dateDetails.date | filter : contactid | limitTo : 1">
    <tr>
        <td>Joint Work</td>
        <td>{{dateDetails.joint_work}}</td>
    </tr>
    <tr>
        <td>Gap</td>
        <td><a href="" ng-click="gap(dateDetails.date)">Click Me</a></td>
    </tr>
</div>

in above code, I have put ng-click, after which the function is called. But the function has to be called by default so as to populate one of the columns, which is not happening. the function 'gap' sets $scope.gap to the difference between today's date and the date passed to it. How should I fix the problem?

Problem courtesy of: Ru11

Solution

If you have to do it with markup you can use ng-init

Also, from the same link, can't you set up initial value using your controller?

Solution courtesy of: Darshan Joshi

Discussion

I achieved this function call inside ng-repeat by using ng-init

<td class="lectureClass" ng-repeat="s in sessions" ng-init='presenters=getPresenters(s.id)'>
      {{s.name}}
      <div class="presenterClass" ng-repeat="p in presenters">
          {{p.name}}
      </div>
</td> 

The code on the controller side should look like below

$scope.getPresenters = function(id) {
    return SessionPresenters.get({id: id});
};

While the API factory is as follows:

angular.module('tryme3App').factory('SessionPresenters', function ($resource, DateUtils) {

        return $resource('api/session.Presenters/:id', {}, {
            'query': { method: 'GET', isArray: true},
            'get': {
                method: 'GET', isArray: true
            },
            'update': { method:'PUT' }
        });
    });
Discussion courtesy of: Sacky San

This recipe can be found in it's original form on Stack Over Flow.