我在 spa 中使用 MatDialog,需要将 MatDialogConfig 传递给已调用的组件。有什么办法吗?
我想从组件模板将数组传递给函数。
这是我的工具栏:
toolbar.component.html
<div *ngFor="let item of items">
<button mat-mini-fab [style.color]="item.color"
(click)="item.command(...item.commandParams)">
<i class="material-icons">{{item.icon}}</mat-icon>
</button>
</div>
Run Code Online (Sandbox Code Playgroud)
工具栏.component.ts
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-toolbar',
templateUrl: './toolbar.component.html',
styleUrls: ['./toolbar.component.scss']
})
export class ToolbarComponent implements OnInit {
items: ToolBarItem[]
constructor() {
}
ngOnInit() {
}
}
export class ToolBarItem {
icon = 'border_clear';
color: string;
command: () => void;
commandParams: any[];
}
Run Code Online (Sandbox Code Playgroud)
在这里,我想使用各种命令来初始化工具栏的项目。
主要
...
items: [
{
icon: 'mode_edit',
color: 'blue',
command: (name, family) => {
console.log('editClick!' + …
Run Code Online (Sandbox Code Playgroud)