Skip to content
This repository was archived by the owner on Apr 30, 2018. It is now read-only.

Errors and Warnings

Kent C. Dodds edited this page Jan 27, 2015 · 8 revisions

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.

Couldn't set the formControl after {time}ms

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:

  1. The field has no form on the scope (shouldn't happen if you're using the latest version and the formly-form directive)
  2. The element with the ng-model attribute for the field's template doesn't use the name property with the id property of the scope (i.e. name={{::id}} or in angular 1.2 formly-dynamic-name="id") <-- this is the most likely reason

Fixes for this warning are:

  1. Add the appropriate attribute to the element with the ng-model attribute for the field's template so it has a name (as mentioned above)
  2. On the field options, specify noFormControl: true

Problem loading template for {templateUrl}

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:

  1. Make sure that the URL is correct and that you're able to reach that URL (paste it into your browser to test)
  2. Use template instead of templateUrl. This can be a little crazy for bigger templates. However, if you use Webpack's raw-loader then it's as simple as require('./my-formly-template.html'). This is what I do, and it's a beautiful thing :-)

template type {type} not supported.

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.

You must provide one of type, template or templateUrl for a field

I feel like this is fairly self explanatory. Make sure you're only specifying one of the three options there for each field.

You must only provide a type, template, or templateUrl for a field

Same as above.

All field watchers must have a listener

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.

Notes

It is recommended to disable warnings in production using formlyConfigProvider.disableWarnings = true. Note: This will not disable thrown errors, only the console.warn messages.

Clone this wiki locally