import {NgModule} from '@angular/core';
import {ReactiveFormsModule} from '@angular/forms';
import {CanhcamModule} from 'ngx-cc-template-core';
import {CanhcamBootstrapModule} from 'ngx-cc-template-bootstrap';
@NgModule({
imports: [
...,
ReactiveFormsModule,
CanhcamModule.forRoot(),
CanhcamBootstrapModule,
],
})
export class AppModule {}
import {Component} from '@angular/core';
import {FormGroup} from '@angular/forms';
import {CanhcamFieldConfig} from 'ngx-cc-template-core';
@Component({
selector: 'app',
template: `
<form [formGroup]="form" (ngSubmit)="submit(userModel)">
<canhcam-form [model]="userModel" [fields]="userFields">
<button type="submit" class="btn btn-default">Submit</button>
</canhcam-form>
</form>
`,
})
export class AppComponent {
form = new FormGroup({});
userModel = { email: 'email@gmail.com' };
userFields: Array<CanhcamFieldConfig> = [{
key: 'email',
type: 'input',
templateOptions: {
type: 'email',
label: 'Email address',
placeholder: 'Enter email',
required: true,
}
}];
submit(user) {
console.log(user);
}
}