Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

119
Views
DeepCopy in Angularjs?

Is there a way to add the $scope data to another $scope without changing the values from which it is added? Currently, I have created one button and whenever someones click on it the following action is performed.

    $scope.updateShiftSummary = function () {
        $scope.shiftModalSummary = $scope.shiftSummary;
        $('#updateShiftModal').modal('show');
    };

Since I am working on an update and whenever someone adds shifts following action is performed but if someone closes the modal without saving the form the $scope.shiftSummary also gets updated and the new data is also pushed in it so how to update the $scope.shiftModalSummary only without affecting the data in $scope.shiftSummary

 $scope.addShift = function () {
        var shiftSummary = $scope.shiftModalSummary;
        var totalShifts = shiftSummary.length;
        var lastShift = shiftSummary[totalShifts - 1].shiftName.split(" ");
        var shiftValue = parseInt(lastShift[1]) + 1;
        var shiftTime = new Date(new Date().setHours(0, 0, 0, 0));
        shiftSummary.push({
            'shiftName': 'Shift ' + shiftValue,
            'startTime': shiftTime,
            'endTime': shiftTime,
            'staffName': 'Owner'
        });
    };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

$scope.updateShiftSummary = function () {
    $scope.shiftModalSummary = angular.copy($scope.shiftSummary); <---
    $('#updateShiftModal').modal('show');
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!