Support two objects
$scope.shipping = { .... }; $scope.billing = { .... };
If someone chooses what they want to combine, just do
$scope.billing = $scope.shipping.
Since the objects are by reference, since they update one, the other will also be updated. You can remove the link by changing $ scope.billing back to what you initialized it:
$scope.billing = { .... };
If you have a checkbox that you want to associate with this, connect data-ng-change to it
<input type="checkbox" data-ng-model="MY_MODEL" data-ng-change="myFunction() "/>
Then your controller has
$scope.MY_MODEL = false; $scope.myFunction(){ console.log($scope.MY_MODEL); }
Or don't bind data-ng-change and just $ watch MY_MODEL:
$scope.MY_MODEL = false; $scope.$watch("MY_MODEL", function(){ console.log($scope.MY_MODEL); }, true);
source share