### File

`demo/demo.component.ts`

### Implements

`OnInit` `AfterViewInit`

### Metadata

providers | `DemoService`
selector | `rb-demo-app`
template |
    <div class='container'>
      <h1>AngularForms</h1>

      <div class="alert alert-danger" *ngIf="errorMessage">
        <p>{{ errorMessage }}</p>
      </div>

      <rb-angular-forms #angularForms [groups]="customForm" [readOnly]="false" lang="pt-BR" (error)="onError($event)"></rb-angular-forms>

      <button class="btn btn-primary" (click)="angularForms.submit()">submit()</button>
      <button class="btn btn-primary" (click)="isPristine()">isPristine()</button>
      <button class="btn btn-primary" (click)="isDirty()">isDirty()</button>
      <button class="btn btn-primary" (click)="isValid()">isValid()</button>
      <button class="btn btn-primary" (click)="getForm()">getForm()</button>
      <button class="btn btn-primary" (click)="isValid()">isValid()</button>
      <button class="btn btn-primary" (click)="getAnswersGroups()">getAnswersGroups()</button>
      <button class="btn btn-primary" (click)="getAnswers()">getAnswers()</button>
    </div>

### Index

###### Properties
Public angularForms Public customForm Public errorMessage
###### Methods
Public getAnswers Public getAnswersGroups Public getForm Public isDirty Public isPristine Public isValid Public onError

### Constructor

`constructor(demoService: DemoService, changeDetectorRef: ChangeDetectorRef)`
Defined in demo/demo.component.ts:37
Parameters :
Name | Type | Optional | Description
demoService | `DemoService` |  |
changeDetectorRef | `ChangeDetectorRef` |  |

### Methods

Public getAnswers
`getAnswers()`
Defined in demo/demo.component.ts:76
Returns : `void`

Public getAnswersGroups
`getAnswersGroups()`
Defined in demo/demo.component.ts:72
Returns : `void`

Public getForm
`getForm()`
Defined in demo/demo.component.ts:56
Returns : `void`

Public isDirty
`isDirty()`
Defined in demo/demo.component.ts:64
Returns : `void`

Public isPristine
`isPristine()`
Defined in demo/demo.component.ts:60
Returns : `void`

Public isValid
`isValid()`
Defined in demo/demo.component.ts:68
Returns : `void`

Public onError
`onError(error: Error)`
Defined in demo/demo.component.ts:52
Parameters :
Name | Type | Optional | Description
error | `Error` |  |
Returns : `void`

### Properties

Public angularForms
`angularForms: `AngularFormsComponent``
Type : `AngularFormsComponent`
Decorators : `ViewChild`
Defined in demo/demo.component.ts:35

Public customForm
`customForm: `any[]``
Type : `any[]`
Defined in demo/demo.component.ts:33

Public errorMessage
`errorMessage: `string``
Type : `string`
Defined in demo/demo.component.ts:80

    import { AfterViewInit, ChangeDetectorRef, Component, OnInit, ViewChild } from '@angular/core';

    import { DemoService } from './demo.service';
    import { AngularFormsComponent } from '../src';
    import { Fieldset } from '../src/group';

    @Component({
      selector: 'rb-demo-app',
      template: `
        <div class='container'>
          <h1>AngularForms</h1>

          <div class="alert alert-danger" *ngIf="errorMessage">
            <p>{{ errorMessage }}</p>
          </div>

          <rb-angular-forms #angularForms [groups]="customForm" [readOnly]="false" lang="pt-BR" (error)="onError($event)"></rb-angular-forms>

          <button class="btn btn-primary" (click)="angularForms.submit()">submit()</button>
          <button class="btn btn-primary" (click)="isPristine()">isPristine()</button>
          <button class="btn btn-primary" (click)="isDirty()">isDirty()</button>
          <button class="btn btn-primary" (click)="isValid()">isValid()</button>
          <button class="btn btn-primary" (click)="getForm()">getForm()</button>
          <button class="btn btn-primary" (click)="isValid()">isValid()</button>
          <button class="btn btn-primary" (click)="getAnswersGroups()">getAnswersGroups()</button>
          <button class="btn btn-primary" (click)="getAnswers()">getAnswers()</button>
        </div>
      `,
      providers: [DemoService]
    })
    export class DemoComponent implements OnInit, AfterViewInit {

      public customForm: any[];

      @ViewChild('angularForms') public angularForms: AngularFormsComponent;

      private _errorMessage: string;

      public constructor(
        private demoService: DemoService,
        private changeDetectorRef: ChangeDetectorRef
      ) { }

      public ngOnInit(): void {
        this.customForm = this.demoService.getForm();
      }

      public ngAfterViewInit(): void {
        this.changeDetectorRef.detectChanges();
      }

      public onError(error: Error): void {
        this._errorMessage = 'Error';
      }

      public getForm(): void {
        console.log(this.angularForms.getForm());
      }

      public isPristine(): void {
        console.log(this.angularForms.isPristine());
      }

      public isDirty(): void {
        console.log(this.angularForms.isDirty());
      }

      public isValid(): void {
        console.log(this.angularForms.isValid());
      }

      public getAnswersGroups(): void {
        console.log(this.angularForms.getAnswersGroups());
      }

      public getAnswers(): void {
        console.log(this.angularForms.getAnswers());
      }

      public get errorMessage(): string {
        return this._errorMessage;
      }
    }

Legend
Html element
Component
Html element with directive

# results matching ""

# No results matching ""