ngx-cc-template-material
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

1. Install @angular/forms and ngx-cc-template-core packages:

  npm install @angular/forms ngx-cc-template-core --save

2. Choose and install your UI (pre-defined types/templates) package:

  npm install ngx-cc-template-material --save
  npm install ngx-cc-template-bootstrap --save

3. Import the CanhcamModule and UI (pre-defined types/templates):

import {NgModule} from '@angular/core';
import {ReactiveFormsModule} from '@angular/forms';
import {CanhcamModule} from 'ngx-cc-template-core';
import {CanhcamBootstrapModule} from 'ngx-cc-template-bootstrap';
 
// for material2 import `CanhcamMaterialModule`:
// import {CanhcamMaterialModule} from 'ngx-cc-template-material';
 
@NgModule({
  imports: [
    ...,
    ReactiveFormsModule,
    CanhcamModule.forRoot(),
    CanhcamBootstrapModule,
 
    // for material2 use:
    // CanhcamMaterialModule
  ],
})
export class AppModule {}

3. Define the form config in your component:

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);
  }
}

/ngx-cc-template-material/

    Package Sidebar

    Install

    npm i ngx-cc-template-material

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • lytk
    • baonguyenyam