Search code examples
angularjsangular-formly

Disable field.hide in angular formly


The default hide directive with angular-formly is ng-if which can be configured via e.g. the formlyConfigProvider.

Currently all my fields should always be shown and I don't want to have unneccesary ng-if="!field.hide" checks rendered that can inpact the performance.

How can I tell formly not to use this check per field/form or globally?


Solution

  • you set hide-directive="ng-show" in the formly-form

    <formly-form    hide-directive="ng-show"></formly-form>
    

    "hide-directive

    Allows you to control the directive used to hide fields. Common value for this might be ng-show. It will be passed !field.hide. You can also specify this on a global level using formlyConfig.extras.defaultHideDirective = 'ng-show'"

    http://docs.angular-formly.com/docs/formly-form

    So you can either set it as I instructed or you can choose to edit it in the config on startup for all fields