Question: I have a datepicker inside of a repeater. Now I need to get the value of the datepicker in my insert function. Everything I try results in 'undefined'. What is the right way to handle this?

```
<div ng-repeat="r in results | filter:searchText">
        <input class="input-datum sdate" ng-model="selecting.sdate" datepicker placeholder="datum van" />
        <input class="input-datum edate" ng-model="selecting.edate" placeholder="datum tot"/>        
        <img src="img/save.png" width="20px" class="icon" ng-click="insertTarief(selecting)"/>
</div>

```

controller:

```
var app = angular.module('DienstenApp', []);

(function () {
    app.controller('DienstenController', ['$scope', '$http', function ($scope, $http) {
            var data = {
                dienstenEdit: 'get',
            };
            $http.post('ajax_crud.php', data).
                    success(function (data, status, headers, config) {
                        $scope.results = data;
                    });

            $scope.insertTarief = function (selectValue) {
                console.log(selectValue);
            };

        }]).directive('datepicker', function ($timeout) {
    var linker = function ($scope, element, attrs, ngModelCtrl) {
        $timeout(function () {
            $(element).datepicker({
                minDate: 0,
                dateFormat: 'dd-mm-yy',
                onSelect: function (y, instance) {
                    var edate = element.siblings('.edate');
                    edate.datepicker();
                    edate.datepicker('option', 'minDate', element.datepicker("getDate"));
                }
            });
        });
    };
    return {
        restrict: 'A',
        require: 'ngModel',
        transclude: true,
        link: linker
    };    
   });
})();

```

Answer: 
Try This 

```
<div ng-repeat="r in results | filter:searchText track by $index">
        <input class="input-datum sdate" ng-model="selecting.sdate[$index]" datepicker placeholder="datum van" />
        <input class="input-datum edate" ng-model="selecting.edate[$index]" placeholder="datum tot"/>        
        <img src="img/save.png" width="20px" class="icon" ng-click="insertTarief($index)"/>
</div>

```

and in controller 

```
 $scope.insertTarief = function (index) {
                console.log(selecting[index]);
            };

```
```
<div ng-repeat="r in results | filter:searchText">
    <input class="input-datum sdate" ng-model="selecting.sdate" datepicker placeholder="datum van" id="{{selecting.sdate}}"/>
    <input class="input-datum edate" ng-model="selecting.edate" placeholder="datum tot"/>        
    <img src="img/save.png" width="20px" class="icon" ng-click="insertTarief(selecting)" id="{{selecting.edate}}"/>

```

> 
> add an id field like above . 
>  and access it like this var aa = $('#'+foo.edate).val();
> 
> 
>