【发布时间】:2021-02-03 18:53:41
【问题描述】:
我有一个 Angular10 组件(切换开关),我需要将它包含在我的 ag-grid(单元格)的特定列中。
目前我有一个标准的 html 复选框,如下所示:
colDefs: ColDef[] = [
{ field: 'Name', headerName: 'Name'},
{ field: 'Somethingelse', headerName: 'Something else'},
{ field: 'Checkbox', headerName: 'A Checkbox', //<--this one
editable:true,
checkboxSelection: false,
headerCheckboxSelection: false,
filter: false,
sortable: false,
cellRenderer: function (params: { value: boolean; }) {. //<--draws this
var input = document.createElement("input");
input.type = "checkbox";
input.checked = params.value;
return input; //<--want to draw my component here instead
} }
];
我想使用的组件而不是复选框已经存在于我的项目中:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'my-toggle-switch',
templateUrl: './toggle-switch.component.html',
styleUrls: ['./toggle-switch.component.scss']
})
export class ToggleSwitchComponent implements OnInit {
selected: boolean = false;
constructor() { }
ngOnInit(): void {}
}
如何包含 Angular10 组件来代替复选框?
【问题讨论】: