Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

angular new formcontrol default value

formtest: FormGroup;// Declare form control

//set defualt values
this.formtest = this.fb.group({
        name: ["test", [Validators.required, Validators.maxLength(30)]],
        mobile: ["9874563211", [Validators.required, Validators.maxLength(10)]],
    });
    
//Or set defualt values to specific controls
this.formtest.controls.name.setValue('test');
this.formtest.controls.mobile.setValue('9874563211');
 
PREVIOUS NEXT
Tagged: #angular #formcontrol #default
ADD COMMENT
Topic
Name
1+7 =