There is an object in which data from the view is collected, then I want to transfer this data to various functions, but when I do as described below, the object does not default to two way binding, and I have to use watch, if there is another way, and variations of the implementation of such same behavior.

var defaultOption = { some: $ctrl.option1, some2: $ctrl.option2 } $scope.$watchGroup(['$ctrl.option1','$ctrl.option2'],myFunc); function myFunc() { defaultOption = { some: $ctrl.option1, some2: $ctrl.option2 } } // Затем я вызываю нужные функции myFunc1(defaultOption) myFunc2(defaultOption) ... 

The problem is that the data is not correct

  • Do you really want to change the default options? - Grundy
  • For example, these are named objects, I want to change the object that will then be thrown into the function - MoJlo4HuK
  • try to write a more detailed example of use in the question - Grundy
  • @Grundy Described in more detail - MoJlo4HuK
  • in this case - no way. Inside functions, the parameter will always refer to the old variable, since you are changing the whole object. By the way, I did not understand why not to put this object in the controller and not to bind it exactly? - Grundy

0