@ngx-reflective-forms/ionic
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

Angular Forms Powered By Reflection
Ionic Library

dependency-status dev-dependency-status codecov-status

Getting Started

export class TestFormModel {
  name: string;
  surname: string;
  attributeWithoutControl = 10;
}
@Injectable()
export class TestFormGroup extends FormGroup<TestFormModel> {
  @Control()
  @Default("Miguel")
  @Validator(TestFormValidator.validateName)
  public name: TextFormControl = undefined as any;

  @Control()
  @Default("Franken")
  public surname: TextFormControl = undefined as any;
}
export class TestFormValidator {
    public static validateName(this: TextFormControl): void {
      if (this.value.length > 5) {
        throw new ValidationError("Max. 5 Characters");
      }
    }
}
@Component({
  selector: "app-root",
  templateUrl: "./app.component.html",
  providers: [TestFormGroup],
})
export class AppComponent implements OnInit {
  constructor(private form: TestFormGroup) {
  }
  
  ngOnInit(): void {
    this.form.init();
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @ngx-reflective-forms/ionic

Weekly Downloads

0

Version

0.0.8

License

MIT

Unpacked Size

202 kB

Total Files

71

Last publish

Collaborators

  • miguel.franken