How to add dynamic values to the <mat-label> in angular 9?

Viewed 2541

I am trying to display a read only review page in Angular 9 with all the inputs given in a previously completed form. If i want to use mat-label, how to use the ngModel ?

Eg.,

Username : ABC; Email Id : abc@abc.com

"ABC" and "abc@abc.com" should be fetched from the previously filled form. How can I achieve this? Thanks is advance!

1 Answers

What I recommend you to do is to use the two way binding for your inputs as they are only read only.

Eg

The first step:

.ts

private email:string;

.html

<input [(ngModel)]="email"/>

Second readonly step. If they are in the same component just user the variable binding

.html(same .ts)

<mat-label>{{email}}</mat-label>

If the two pages are not in the same component then you can use services to highlight the variable into a service and then you can access from both components the value of it

Related