Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to use `ngx-sub-form` with template driven forms?

See original GitHub issue

Is it possible to use ngx-sub-form with template driven forms?

This means using ngModel, ngModelGroup + directive validation?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

andreElricocommented, Jun 12, 2019

Yes it really takes out the complexity of react. forms. Ill def give it a try.

maxime1992commented, Jun 11, 2019

Just to demo what I’m talking about @andreElrico, if you look into the MedicalDroidComponent:

  selector: 'app-medical-droid',
  templateUrl: './medical-droid.component.html',
  styleUrls: ['./medical-droid.component.scss'],
  providers: subformComponentProviders(MedicalDroidComponent),
export class MedicalDroidComponent extends NgxSubFormComponent<MedicalDroid> {
  protected getFormControls(): Controls<MedicalDroid> {
    return {
      color: new FormControl(null, { validators: [Validators.required] }),
      name: new FormControl(null, { validators: [Validators.required] }),
      droidType: new FormControl(DroidType.MEDICAL, { validators: [Validators.required] }),
      canHealHumans: new FormControl(false, { validators: [Validators.required] }),
      canFixRobots: new FormControl(false, { validators: [Validators.required] }),
<fieldset [formGroup]="formGroup" class="container">
  <legend>Medical Droid Form</legend>

    <input matInput type="color" placeholder="Color" [formControlName]="formControlNames.color" autocomplete="off" />

    <input matInput type="text" placeholder="Name" [formControlName]="" autocomplete="off" />

  <mat-slide-toggle [formControlName]="formControlNames.canHealHumans">Can heal humans</mat-slide-toggle>

  <mat-slide-toggle [formControlName]="formControlNames.canFixRobots">Can fix robots</mat-slide-toggle>

Could you maybe rewrite that as template driven form to compare?

I think the boilerplate here is fairly small, but would be interesting to have something to compare to 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Building a template-driven form
This tutorial shows you how to create a template-driven form. The control elements in the form are bound to data properties that have...
Read more >
Angular Forms Guide: Template Driven and Reactive Forms
This post is an in-depth comparison between the two different alternatives for building forms in Angular - Template Driven Forms and ...
Read more >
Template Forms are just as powerful as Reactive Forms
There are two form packages in Angular, Forms, for template-driven forms, and Reactive Forms, for logic-driven forms.
Read more >
Start using ngx-sub-form in your project by running `npm i ngx-sub-form`. ... (based on some JSON configuration for example) ngx-sub-form is ...
Read more >
A practical guide to Angular Template-Driven Forms
Form Building Blocks. First, we need some basic controls before we're able to construct a usable form. In this section, we'll take a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found