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