Lets say that I have a form with one dropdown with options foo, bar and 3 input fields: input1, input2 and input3. All formfields ar binded to a $scope object.
I would like to make a setup where if the user in the dropdown selects:
- foo, then $watch listens to changes in input1 and input2 but not input3.
- bar, then $watch listens to changes in input3 but not input1 and input2.
On change detection, depending which option was selected in the dropdown, a function in the controller should be called: function foo () or function bar ().
And to complicate things even more the called function should check if the according input fields are valid. If yes, then do some bussiness logic with the input field values and store the result on a $scope.