【发布时间】:2019-10-30 16:22:25
【问题描述】:
我有一个表格,其中包含一个单元格中的自定义组件和一个为我提供一些数据来显示的服务。 我的自定义组件实现了选择。 因此,表格的列如下所示:
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);
}
}
似乎instance 对象应该具有options 属性(因为它在@Input 下),但它没有:(
我试过类似的东西
https://github.com/akveo/ng2-smart-table/issues/521#issuecomment-333273103
但它对我不起作用,因为我需要来自 Observable 的数据。
【问题讨论】: