Hi
Below is the data returned.I am trying below Html. I want to display only Name & Email.
In List Data there are more than 2 columns like Id,Name,Email,Contact No. etc.
{{ column }}
{{ element[column] }}
@Input() arrChildHead: string[] = [];
@Input() lstChild: any[] = [];
In arrChildHead it has 2 fields Name,Email.
In Lstchild it is data which is returned through API.
Thanks
Sigar DavePosted Jul 3, 2024, 11:55 AM
Please ensure the
idandforattributes are set correctly for each iteration.something like this
Ramco RamcoPosted Jul 3, 2024, 11:43 AM
Hi Dave
I am getting this error. Below is the TypeScript
The label's
forattribute doesn't match any elementid. This might prevent the browser from correctly autofilling the form and accessibility tools from working correctly.To fix this issue, make sure the label's
forattribute references the correctidof a form field.Thanks
Sigar DavePosted Jul 3, 2024, 11:31 AM
To display only the "Name" and "Email" columns from your data using Angular and Angular Material, you need to make sure that
arrChildHeadcontains only those two columns and that yourdisplayedColumnsarray is set accordingly. Here's a step-by-step solution:displayedColumnsarray:Ensure that
displayedColumnsonly includes "Name" and "Email".Modify the
*ngFordirective to iterate over thedisplayedColumnsarray and bind data correctly.Here's how you can structure your component:
And your component TypeScript file should look like this:
With this setup:
arrChildHeadshould only include the column names "Name" and "Email".displayedColumnswill take the values fromarrChildHead.The HTML template iterates over
displayedColumnsand displays only the "Name" and "Email" columns from your data.Make sure that your data in
lstChildcontains the corresponding fields "Name" and "Email". For example, your data array might look something like this:With this configuration, only the "Name" and "Email" columns will be displayed in the table.