0

When my app loads, it sends a request to the back-end to load a coarse grained JSON payload and I store it in $scope.data.

Then I want to fetch a property from $scope.data and store it in $scope.netWorkDetails (code is just an example):

$scope.networkDetails = {
  type: $scope.data.network.type;
}

Is there a way to bind $scope.networkDetails to $scope.data.network.type, so that it gets updated whenever $scope.networkDetails changes?

TheFooProgrammer
  • 2,439
  • 5
  • 28
  • 43

1 Answers1

1

Looks like I should use scope.$watch...

In case someone else stumbles upon this problem:

$scope.$watch("myModel.fullName", function(newValue, oldValue) {
  $scope.myOtherModel = {
     fullName: newValue
  };
});
TheFooProgrammer
  • 2,439
  • 5
  • 28
  • 43