bia-framework
Version:
Bia Framework to work with angular 2
60 lines (52 loc) • 1.48 kB
text/typescript
import {Component, OnInit, Output, EventEmitter, Host, ViewEncapsulation} from "@angular/core";
import {FORM_DIRECTIVES, ControlGroup, Control} from "@angular/common";
/**
* Created by jd on 04/02/2016.
*/
export class CoreForm implements OnInit
{
form:ControlGroup = new ControlGroup({});
sub = new EventEmitter();
//@Host() ngForm:ControlGroup
constructor()
{
// this.form = new ControlGroup({});
}
public addControl = (name:string, control:Control):void =>
{
if (this.form == null)
{
//this.form = new ControlGroup({});
this.form.addControl(name, control);
}
else
{
this.form.addControl(name, control)
}
};
ngOnInit():any
{
return undefined;
}
public onSubmit = (data:ControlGroup):void =>
{
if (this.form && this.form.valid)
{
this.sub.emit(data);
}
};
}