I am learning how to use angular js formly, and saw this example about required field. http://angular-formly.com/#/example/other/toggle-required
But I don't really understand ng-messages="fc.$error"
here. Why it is fc.$error
? where does the fc come from? I changed the fc
to any other name, then it stops working....
so confused, anyone could explain? Thanks!
fc
is a shortcut foroptions.formControl
. See the docs. TheformControl
is the field's instance of theNgModelController
which is where$error
comes from (and that's what ngMessages is expecting). This is why passing anything else to it stops working.