I am currently working on a wrapper for the forms. Everthing works beside the validation.The problem is that my ngForm property does not contain the controls from the ng-content. The goal is that the ngSubmit EventEmitter only emits if the form is valid.
This is the current status:
import { Component, Input, ViewChild, Output, EventEmitter } from '@angular/core';
import { NgForm } from '@angular/forms';
@Component({
selector: 'px-form',
template: `
<form (ngSubmit)="f.form.valid && ngSubmit.emit($event)" #f="ngForm">
<ng-content></ng-content>
</form>
})
export class PxFormComponent {
@ViewChild('f') ngForm: NgForm;
@Output() ngSubmit = new EventEmitter();
}