Template improvements

If we take another look at our CityEditComponent and CountryEditComponent template files, we can definitely see a certain amount of code bloat. The form.get() method is called no less than 10 times per form, and poses a serious threat to our template's readability. And we're talking about very small and easy forms. What would happen when dealing with big ones? Is there a way to address that?

As a matter of fact, there is: whenever we feel like we're writing too much code or repeating a complex task too many times, we can create one or more helper methods within our Component class in order to centralize the underlying logic. These helper methods will act as shortcuts that we can call instead of repeating the whole validation ...

Get ASP.NET Core 3 and Angular 9 - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.