質問

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