I have a component that I created and its called options because it renders edit and delete button. Then I have a table component that is reusable. I inject the table component into a view on the site. Then I import the options component but I don't display it on that view because I want to pass it to the table component and render it to tag. Is there away to pass the options component from main component to the table component with injecting it because not not tables with have the same options component.
options.component.ts
@Component({
selector: 'options',
template: `
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-secondary active">
<input type="radio" name="options" id="option" autocomplete="off" checked>Edit
</label>
<label class="btn btn-danger">
<input type="radio" name="options" id="option" autocomplete="off" checked>Delete
</label>
</div>`,
styles: []
})
export class OptionsComponent implements OnInit {
constructor() { }
ngOnInit() { }
}
main.component.ts
import { TableComponent } 'file location here';
import { OptionsComponent } 'file location here'; // Component is injected here and I want to pass it to <app-table></app-table>
@Component({
selector: 'app-main',
template:'<app-table [tableData]="LocationsList"></app-table>'
})
export MainComponent implements OnInit {
LocationsList: []; // list of locations
}
table.row.component.ts
@Component({
selector: 'app-table',
template: `
<ul>
<li *ngFor="let property of tableData">{{ property }}</li>
</ul>`,
})
export class TableComponent implements OnInit {
@Input() tableData: any[];
}