Issue
.get()
is not working for an object in TypeScript. In HTML I am unable to access the max
value of the dataFormparams
object.
export interface FormBUilderParams extends Object {
required: boolean;
minlength: number;
maxlength: number;
regx: string
}
dataFormparams!: FormBUilderParams;
Object.defineProperty(this.dataFormparams, "element.controllName", {
required: element.required,
minlength: element.minlength,
maxlength: element.maxlength,
regx: element.regx
});
<mat-hint align="start">Min {{dataFormparams.get('name').minlength}} and Max {{dataFormparams.get('name').maxlength} Characters</mat-hint>
Solution
You can use this way
reactiveForm: FormGroup;
this.reactiveForm = this.formBuilder.group({
email: [null, [
Validators.required,
]
});
// convenience getter for easy access to form fields
get f() { return this.reactiveForm.controls; }
Answered By - Siddhartha Mukherjee
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.