$scope.property
을 다른 변수 var query
의 값으로 정의하여 복사 중이며 var query
의 값을 업데이트하면 값이 변경됩니다. $scope.property
.
왜 이런 일이 발생하며이를 피할 수 있습니까?
var query = $scope.property;
if(condition) {
console.log($scope.property);
$.extend(query, anotherObj);
console.log($scope.property);
}
콘솔의 출력은 다음과 같습니다 : 나는 바닐라 자바 스크립트에서이 문제가 발생한 적이
> Object {details-type: "order", details-bind_date_formatted: "03/19/2013"}
> Object {details-type: "order", details-bind_date_formatted: "03/19/2013", details-state: "CA"}
내 코드는 다음과 같이 보입니다.
나는 각도 및 이전에 응답 한 데와는 아무 상관이없는이 질문을 신고해야 하는가? –