Reputation: 399
I am currently working on one of my first angular projects and I'm struggling to decide on what approach to take best.
The project i'm working on consists out of a form that holds a financial simulation (think of it as putting an xls sheet into an angular app).
Changing values in one form input (xls cell) has to result in other fields automatically being recalculated. These fields can be spread over multiple rows.
Currently I am trying to do this using the reactive forms module, but I'm having trouble responding to events when elements change (as I dont feel like implementing (change) on each field seems like a good idea).
Isn't there some way i can just bind the values to object properties and calculate them this way?
To provide some additional context: I am creating a profitability simulator for companies that have consultants. So each row contains a consultant with its cost, purchase price, daily rate etc.
I was thinking now to switch/refactor to template driven forms to use ([ngModel])...
All suggestions / approaches are very much appreciated!
Best
Upvotes: 0
Views: 1652
Reputation: 11
All controls on reactive forms are observables. You can subscribe to the form group on changes, and process all changes to the form group, or any nested form group that may exist - and access the changes. I don't know why ngModel was not supported for reactive forms in Angular 7 - it seems to me to be a bad move. Many people will be driven away from reactive forms due to this - and that is a shame.
Upvotes: 1