小编M_F*_*and的帖子

如何从被调用组件内部访问 MatDialogConfig?

我在 spa 中使用 MatDialog,需要将 MatDialogConfig 传递给已调用的组件。有什么办法吗?

angular-material2 angular

6
推荐指数
1
解决办法
9450
查看次数

如何在角度组件模板中使用Spread Operator

我想从组件模板将数组传递给函数。
这是我的工具栏:
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)

angular

5
推荐指数
1
解决办法
3179
查看次数

标签 统计

angular ×2

angular-material2 ×1