-
Notifications
You must be signed in to change notification settings - Fork 398
Errors and Warnings
Angular formly provides you with some handy warnings and errors to keep you from using it incorrectly. It will direct you to these for additional help. If these don't help you, please file an issue on GitHub or join us on Gitter.
For every field, Angular formly will attempt to set a property on the options called formControl. This is the NgModelController for that field. Possible reasons you could be seeing this are:
- The field has no form on the scope (shouldn't happen if you're using the latest version and the
formly-formdirective) - The element with the
ng-modelattribute for the field's template doesn't use thenameproperty with theidproperty of the scope (i.e.name={{::id}}or in angular 1.2formly-dynamic-name="id") <-- this is the most likely reason
Fixes for this warning are:
- Add the appropriate attribute to the element with the
ng-modelattribute for the field's template so it has a name (as mentioned above) - On the field options, specify
noFormControl: true
If you provide a templateUrl as a property for a formly field or for a preconfigured template type, formly will attempt to load that template using $http with the $templateCache. If this request fails for some reason, you will see this warning.
Fixes for this warning are:
- Make sure that the URL is correct and that you're able to reach that URL (paste it into your browser to test)
- Use
templateinstead oftemplateUrl. This can be a little crazy for bigger templates. However, if you use Webpack'sraw-loaderthen it's as simple asrequire('./my-formly-template.html'). This is what I do, and it's a beautiful thing :-)
You may see this as template type undefined not supported if you do, you failed to specify a type, template or templateUrl for a field. You must specify at least one. If you do see a type there then it is likely that the specified type was never registered with the formlyConfigProvider using setTemplate or setTemplateUrl. Do that.
I feel like this is fairly self explanatory. Make sure you're only specifying one of the three options there for each field.
Same as above.
If you're using the watcher property, it can be an object (called a watcher object) or an array of watcher objects. Either way, all watchers must have a listener property which is a string (expression) or a function. The expression property is optional and you will not receive a warning for this property. See the documentation for more information.
It is recommended to disable warnings in production using formlyConfigProvider.disableWarnings = true. Note: This will not disable thrown errors, only the console.warn messages.