angular - 带有子扩展面板的角材料扩展面板
问题描述
实际上我已经使用角材料扩展面板(手风琴)进行面板扩展。所以我尝试过的是我只想在一个父扩展面板中显示子面板,就像这样。见下图。
数据库将成为顶级父面板,在其中我有不同的数据库作为子面板。为此,我编写了这样的代码。但是代码不起作用意味着当我单击子面板内的任何父面板时,一切都会崩溃。我的意思是说面板正在崩溃。请参见下面的代码:
<mat-accordion>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
Databases
</mat-panel-title>
</mat-expansion-panel-header>
<mat-expansion-panel (opened)="panelOpenState = true"
(closed)="panelOpenState = false">
<mat-expansion-panel-header>
<mat-panel-title>
MySQL
</mat-panel-title>
</mat-expansion-panel-header>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
</mat-expansion-panel>
<mat-expansion-panel (opened)="panelOpenState = true"
(closed)="panelOpenState = false">
<mat-expansion-panel-header>
<mat-panel-title>
Oracle
</mat-panel-title>
</mat-expansion-panel-header>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
</mat-expansion-panel>
<mat-expansion-panel (opened)="panelOpenState = true"
(closed)="panelOpenState = false">
<mat-expansion-panel-header>
<mat-panel-title>
Postgres
</mat-panel-title>
</mat-expansion-panel-header>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
</mat-expansion-panel>
<mat-expansion-panel (opened)="panelOpenState = true"
(closed)="panelOpenState = false">
<mat-expansion-panel-header>
<mat-panel-title>
SQLServer
</mat-panel-title>
</mat-expansion-panel-header>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
</mat-expansion-panel>
<mat-expansion-panel (opened)="panelOpenState = true"
(closed)="panelOpenState = false">
<mat-expansion-panel-header>
<mat-panel-title>
MongoDB
</mat-panel-title>
</mat-expansion-panel-header>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
<mat-form-field>
<textarea matInput placeholder="Assertions"></textarea>
</mat-form-field>
</mat-expansion-panel>
</mat-expansion-panel>
</mat-accordion>
我的计划是只显示那个特定的面板。这很奇怪,它对我不起作用。如果我将扩展面板放在单独的面板中,那么为我工作。有人可以建议我吗?
解决方案
从今天开始,你可以。看到这个堆栈闪电战
<!-- level 01 -->
<mat-accordion>
<mat-expansion-panel
(opened)="panelOpenState = true"
(closed)="panelOpenState = false"
>
<mat-expansion-panel-header>
<mat-panel-title>Week 01</mat-panel-title>
<mat-panel-description>1 entry</mat-panel-description>
</mat-expansion-panel-header>
<mat-accordion>
<mat-expansion-panel
(opened)="panelOpenState = true"
(closed)="panelOpenState = false"
>
<mat-expansion-panel-header>
<mat-panel-title>Day 01</mat-panel-title>
<mat-panel-description>Temperature warning</mat-panel-description>
</mat-expansion-panel-header>
<p>On day #1 of the 1nd week an alarm was raised</p>
</mat-expansion-panel>
</mat-accordion>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>Week 02</mat-panel-title>
<mat-panel-description>2 entries</mat-panel-description>
</mat-expansion-panel-header>
<!-- level 02 -->
<mat-accordion>
<mat-expansion-panel
(opened)="panelOpenState = true"
(closed)="panelOpenState = false"
>
<mat-expansion-panel-header>
<mat-panel-title>Day 01</mat-panel-title>
<mat-panel-description>Production success</mat-panel-description>
</mat-expansion-panel-header>
<p>On day #1 of the 2nd week The production was successful!</p>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>Day 02</mat-panel-title>
<mat-panel-description>2 entries</mat-panel-description>
</mat-expansion-panel-header>
<!-- level 03 -->
<mat-accordion>
<mat-expansion-panel
(opened)="panelOpenState = true"
(closed)="panelOpenState = false"
>
<mat-expansion-panel-header>
<mat-panel-title>03:00</mat-panel-title>
<mat-panel-description>Alarm</mat-panel-description>
</mat-expansion-panel-header>
<p>On day two at 3am was an alarm</p>
</mat-expansion-panel>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>10:00</mat-panel-title>
<mat-panel-description>Info</mat-panel-description>
</mat-expansion-panel-header>
<p>Delievery was successfull</p>
</mat-expansion-panel>
</mat-accordion>
</mat-expansion-panel>
</mat-accordion>
</mat-expansion-panel>
</mat-accordion>
推荐阅读
- azure - 使用 Azure PowerShell 中的两个帐户在 kubernetes 上工作
- c# - 不要等待异步方法,但 VS 会发出警告
- heroku - 为什么 Heroku 构建缓存随着每个版本的发布而变得越来越大?
- elf - 按部分过滤 GNU nm 的输出
- php - 如何使用 arg 中未知数量的参数创建用于插入/更新/删除的 PDO 类方法
- sql - 根据条件从相同列中选择单个值
- flutter - 像 iBooks 一样翻页过渡
- c# - 是否可以从对象继承自同一基类的 2 个表中连接查询?
- vue.js - v-model 两次触发 change 事件
- postgresql - 仅保留第一列的第一个值并根据层次结构对其他两列进行排序