Currently, I am creating an Angular application that includes a form with approximately 15 controls for a finance-related application. I would appreciate advice on how to improve the structure without suggesting a complete page overhaul.
Several of the controls are interdependent. Five input controls act as sources and can impact five other controls that serve as destinations. To handle this, I have implemented $scope.$watch on each source variable and included specific logic in the watch functions to determine which destination variables need updates. Below is an example of one such watch function:
$scope.$watch('money.price',function(newVal,oldVal) {
if(newVal != oldVal) {
if($scope.money.quantity != undefined) {
updatePrincipal($scope)
updateFees($scope);
$scope.money.net = $scope.money.principal + $scope.money.fee
}
}
});
Despite the functionality working, I feel there might be a more elegant solution. Are there any suggestions on how to enhance or streamline this process? (Please keep in mind that the form may become slightly more complex in the future with 2-3 additional dependency fields, but not exceeding that).