Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
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 Respuestas
Responde la pregunta

0

$scope.updateShiftSummary = function () {
    $scope.shiftModalSummary = angular.copy($scope.shiftSummary); <---
    $('#updateShiftModal').modal('show');
};
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda