我有一个表格,单元格中有一个自定义组件,还有一个服务为我提供一些要显示的数据。我的自定义组件实现了 select。因此,表的列如下所示:
userRole: {
title: 'User Role,
type: 'custom',
renderComponent: SelectComponent,
onComponentInitFunction: (instance) => {
instance.selectEdit
.subscribe( (data) => {
console.log(data);
});
}
},
Run Code Online (Sandbox Code Playgroud)
选择.component.html:
<select #select
(change)="callType(select.value)"
>
<option *ngFor="let option of options"
attr.value="option.id" >{{option.name}}</option>
</select>
Run Code Online (Sandbox Code Playgroud)
选择.组件.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);
}
}
Run Code Online (Sandbox Code Playgroud)
似乎instance对象应该具有 …