Hi
I have below array for Header information . I want to give proper Headings to table columns. What changes need to be done in Html
arrheader = [
{'Head': 'Category','FieldName': 'categoryName'},
{'Head': 'Name','FieldName': 'productName'},
{'Head': 'Description','FieldName': 'productDescription'},
{'Head': 'Price','FieldName': 'productPrice'}
]
import { Component, Input } from '@angular/core';
@Component({
selector: 'app-dynamic-table',
template: `
{{ header }}
{{ element[header] }}
`,
})
export class DynamicTableComponent {
@Input() arrHeader: any = [];
@Input() arrGrid: any = [];
}
Thanks
Prasad RaveendranPosted Jun 24, 2024, 10:58 PM
Using standalone components in Angular, you can create a more modular and isolated setup without the need for an
Step 1: Create the Standalone ComponentNgModule. Here's how you can achieve the dynamic table using Angular standalone components in version 17.First, create a standalone component for your dynamic table. This component will have the same logic and template as before but will be defined as a standalone component.
dynamic-table.component.ts
Step 2: Use the Standalone Component in Your Main Application Componentapp.component.ts
Step 3: Bootstrap Your Standalone Applicationmain.ts
SummaryStandalone Dynamic Table Component:
standalone: true.MatTableModuledirectly in the component.Standalone App Component:
DynamicTableComponentdirectly without needing anNgModule.Bootstrap Application:
bootstrapApplicationto bootstrap theAppComponent.This approach leverages Angular's standalone component features to create a more modular and isolated setup, allowing for easy maintenance and scalability.
Jithu ThomasPosted Jun 24, 2024, 7:58 PM
This is a basic implementation, make changes and test.
Regards,