I'm having some trouble understanding why I cant get my components to render. I have an array of strings that I would like to render has table head components. However, when it is just rendering the whole array.
Here is my code:
@Component({
selector: 'app-tableheader',
templateUrl: './tableheader.component.html',
styleUrls: ['./tableheader.component.css']
})
// This should be table header component
export class TableheaderComponent implements OnInit {
@Input() key
@Input() value
headers;
constructor() {}
ngOnInit(){
this.headers = [];
this.value.map((item, index) => this.headers.push(Object.keys(item)));
}
}
----------------
<thead *ngFor="let header of headers">
<th> {{ header }} </th>
</thead>
I would like them to render in a top-level table component.
keyandvaluewith anInputdecorator. What did you pass to the component when you called it?<pre>{{ headers | json}}</pre>? It will render the headers object to the page so that you can 'see' what's in it. Please post back here if you're still having trouble.