setControlValue

Description

  • set an value for the any of the control in the formGroup

  • parameters

    • formControlName : string

    • value : string

Example

import { NgMatFormOptions, NgMatFormFields, NgMatFormService } from 'ng-mat-forms';
// other imports here...

export class MyTestApp {

    public ngMatFormsOptions: NgMatFormOptions = {
        column: 3
        // other options...
    };

    public ngMatFormFields: NgMatFormFields[] = [{
        type: 'input',
        label: 'User Name',
        placeholder: 'Enter a User Name',
        formControlName: 'name'
        // other options...
    }];
    
    setValue(): void {
        //this.ngMatFormService.setControlValue(formControlName:string, name:string): void;
        this.ngMatFormService.setControlValue('name', 'msk');
    }

    constructor(private ngMatFormService:NgMatFormService) {}
}

Last updated