Please read about how directives can communicate in angular before getting started.
When providing a registration form, it's common to repeat password field in order to verify that there were no typo in the entered password. This field is valid only when it matches the value of password field. So we want to develop a matches directive which adds this validator to ngModel. ngModel will run our validator whenever model value changes. Note that for our validator, it's not sufficient to validate on changes of model value (why?)
matches directive should be used like this:
You can fork the plunk below as a starting point: