Angular is a platform for building mobile and desktop web applications. Join the community of millions of developers who build compelling user interfaces with Angular.
@kara - I was aware of the
disable
method, but it's not the same, at least not in my case.Let me take a bit more complicated example than what we can see above. I have a form composed of roughly 70 to 80 fields split across several components. Some part of the form is disabled/enabled, shown/hidden based on either some attributes of the record (on load, or on save), or depending on the user viewing this record, or even from where the record is being called (i.e. different route). I'm playing with the
disabled
and ngIf
attribute / directive (required
is so far always static in my case) but all are defined by, I would call that rules, at the attribute/directive level. This approach is quite consistent for me, ngIf like disabled are all in the html template.Now, if I have to refactor this code based on what you suggest, I will probably need a central function in my class, and call
disable()
or enable()
for each field, based on the value of the form and from external property (user profile, route params, etc.). This function shall subscribe to valueChanges
, and also be called when the component is loaded, or when the save
method is called. Definitely doable, but it feels terribly awkward, at least compared to the current solution, don't you think?Either way, I will have to live with what is implemented. I have so far downgraded the form module to 0.3.0, hoping for a PR resolving the situation above, but based on your comment, I fear this spec is not going to change, is it? Could you please (re)confirm one or the other?
Thanks
Chris
Chris