This part is very important, it’s your last protection before the data are sent to your server so be careful here.
Two ways to do the work:
Let’s modify a bit the template from the previous post:
We only add a field that will be displayed if we have an error in our userForm.
The Observable Way
Back to our Component’s code.
Angular 2 is Observable-Friendly, we can subscribe and listen to many changes now!
To keep it simple, we are only going to use the input name.
We stock the name Controls into a new const named nameControl.
Then we subscribe to the value changes.
Every time the input changes, we make a very basic check, if the input is empty we set a new error that will be named