Angular-material:- 更改 Accordion 中 mat-expansion-panel 的默认图标

标签 angular angular-material

<分区>

下面是 Stackblitz 的链接我正在尝试用图像/其他图标更改图标(箭头)。我尝试使用加号箭头而不是向下箭头。

https://stackblitz.com/edit/angular-wwpb6y?file=styles.css

最佳答案

为您的扩展面板提供一个引用 ID example并设置 hideToggle属性为 true . 将您的图标放在 <mat-panel-description> 中并使用面板的扩展属性显示或隐藏相关图标。

 <mat-expansion-panel  class="custom-header" hideToggle="true" #example>
    <mat-expansion-panel-header>
      <mat-panel-title>
        Collapsible Group Item #1
      </mat-panel-title>
      <mat-panel-description> 
        <mat-icon *ngIf="!example.expanded">add</mat-icon>
        <mat-icon *ngIf="example.expanded">add_box</mat-icon>
      </mat-panel-description>
    </mat-expansion-panel-header>

     <p>
      Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
    </p>
  </mat-expansion-panel>

CSS:

.custom-header .mat-expansion-panel-header-title, 
.custom-header .mat-expansion-panel-header-description {
  flex-basis: 0;
}

.custom-header .mat-expansion-panel-header-description {
  justify-content: space-between;
  align-items: center;
}

同时检查链接:

https://stackblitz.com/edit/angular-irnxvd?file=src%2Fapp%2Fapp.component.css

关于Angular-material:- 更改 Accordion 中 mat-expansion-panel 的默认图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53960607/

相关文章:

javascript - url 中没有哈希字符的情况下,Angular2 的 spa 路由如何工作?

javascript - 如何计算 JS 数组中组的平均值?

javascript - 执行 Angular 函数

javascript - Md-content 的宽度在 cordova 的应用程序中不是 100%

html - Angular Material 垫芯片未设置为可拆卸

angular - typescript 构造函数 : accept string for enum

angular - 从 Angular 2 中的 jquery 调用 TypeScript 方法

javascript - 如何避免 Leaflet Tile Layer WMS 实现中的闪烁?

javascript - Angular Material主题不改变颜色

键入时进行 Angular 响应式(Reactive)表单验证