문제

Hi I'm trying to copy a scope value from one to another scope. For example:

  var items=$scope.order.invoicewindow.items;
  $scope.order.orderwindow.items=items;

However right both scopes are pointing to each other. So if I change $scope.order.orderwindow = "abc", $scope.order.invoicewindow.items also becomes "abc" (which I don't want. I only want $scope.order.orderwindow = "abc").

Thanks

도움이 되었습니까?

해결책

You can use angular.copy(source, [destination]);

var items= "YourValue";
angular.copy(items, $scope.order.invoicewindow.items);
$scope.order.invoicewindow.items = angular.copy(items); //Or You can also use this style
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top