Access value, modify and update within repeater

I've checked but can't find any questions exactly like what I'm looking for - I have a repeater showing each day in a month containing a clock in & out time. Sometimes these times needed to be edited and I would like the function to fire on ng-change with the manual in/out time, call a web service which calculated basic/overtime hours and updates the day totals.

I have the below code

<td class="Cell" ng-repeat="DT in Timesheet.DayTimesheets">
   <input type="text" ng-model="DT.ManualIn" class="DateInput" ng-blur="Changed(DT);"/>
   <input type="text" ng-model="DT.ManualOut" class="DateInput" ng-blur="Changed(DT);" />
   <input number-format type="text" ng-model="DT.TotalStdHoursManual" class="NumberInput" decimals="2" ng-show="Timesheet.EMP.PatternID != null" />
   <input number-format type="text" ng-model="DT.TotalOverTimeHoursManual" class="NumberInput" decimals="2" />

Angular -

    $scope.Changed = function (DT) {
        var GetRequest = $"@Url.Action("CalculateDayTimesheet", "HOME")", { DT: DT })
            .then(function (response) {
                DT =;
                // I want the DT.TotalStdHoursManual updated in the repeater
                // This is not ng-model in above html
                // DT.TotalStdHoursManual  = 1; // Even this doesn't work
            }, function (error) {

Updated DT in the above Angular does not reflect in the ng-model within the repeater.

1 answer

  • answered 2017-10-11 10:10 Icycool

    Assigning an object reference to another object won't modify the object itself:

    var obj1 = {a:1};
    var assign = obj1;
    var obj2 = {a:2};
    var assign = obj2;
    console.log(obj1.a); // 1

    To update the original object instead of just changing the reference, use angular.copy

    angular.copy(, DT);