Angular 2 nested forms with child components and validation

后端 未结 6 1330
醉话见心
醉话见心 2021-02-05 13:16

I\'m trying achieve a nested form with validation in Angular 2, I\'ve seen posts and followed the documentation but I\'m really struggling, hope you can point me in the right di

6条回答
  •  梦谈多话
    2021-02-05 13:53

    import { Directive } from '@angular/core';
    import { ControlContainer, NgForm } from '../../../node_modules/@angular/forms';
    
    @Directive({
      selector: '[ParentProvider]',
      providers: [
        {
        provide: ControlContainer,
        useFactory: function (form: NgForm) {
          return form;
        },
        deps: [NgForm]
        }`enter code here`
      ]
    })
    export class ParentProviderDirective {
    
      constructor() { }
    
    }
    
    for child

提交回复
热议问题