Skip to content

Latest commit

 

History

History
82 lines (68 loc) · 1.52 KB

UPGRADE-2.0.md

File metadata and controls

82 lines (68 loc) · 1.52 KB

UPGRADE FROM ng-formly to @ngx-formly/core

Package name

Before:

import {FormlyModule, FormlyBootstrapModule} from 'ng-formly';

After:

import {FormlyModule} from '@ngx-formly/core';
import {FormlyBootstrapModule} from '@ngx-formly/bootstrap';

FormlyPubSub

The FormlyPubSub service has been removed:

Before:

constructor(private fieldSubject: FormlyPubSub) {}
ngOnInit() {
  this.fieldSubject.getEmitter(this.key).subscribe(event => {
      // ....
  })
}

After:

constructor() {}
ngOnInit() {
  this.options.fieldChanges.subscribe(event => {
      // ....
  })
}

FormlyValidationMessages

The FormlyValidationMessages service has been removed:

Before:

import { FormlyValidationMessages } from '@ngx-formly/core';
...
constructor(private formlyMessages: FormlyValidationMessages) {}
test(): string {
  this.formlyMessages.addStringMessage('required', 'This field is required.');
  this.formlyMessages.getValidatorErrorMessage('required');
}

After:

import { FormlyConfig } from '@ngx-formly/core';
...
constructor(private formlyConfig: FormlyConfig) {}
test(): string {
  this.formlyConfig.addValidatorMessage('required', 'This field is required.');
  this.formlyConfig.getValidatorMessage('required');
}

showError

valid has been replaced by showError:

Before:

<div *ngIf="!valid"></div>

After:

<div *ngIf="showError"></div>