I have a table with a custom component in a cell and a service that provides me some data to display. My custom component implements select. So, table's column looks like this:
userRole: {
title: 'User Role,
type: 'custom',
renderComponent: SelectComponent,
onComponentInitFunction: (instance) => {
instance.selectEdit
.subscribe( (data) => {
console.log(data);
});
}
},
select.component.html:
<select #select
(change)="callType(select.value)"
>
<option *ngFor="let option of options"
attr.value="option.id" >{{option.name}}</option>
</select>
select.component.ts:
export class SelectComponent implements OnInit, OnChanges, ViewCell {
@Input() value: string | number;
@Input() rowData: any;
@Input() options;
@Output() selectEdit = new EventEmitter();
constructor() {
}
ngOnInit() {
}
ngOnChanges(changes: SimpleChanges): void {
}
callType(event) {
this.selectEdit.emit(event);
}
}
Seems like instance
object should have options
property (because it's under @Input
), but it doesn't :(
I've tried somethng like
https://github.com/akveo/ng2-smart-table/issues/521#issuecomment-333273103
but it doesn't work for me because I need data from Observable.