gpt4 book ai didi

带子扩展面板的 Angular Material 扩展面板

转载 作者:行者123 更新时间:2023-12-04 00:30:47 27 4
gpt4 key购买 nike

实际上我已经使用 Angular Material 扩展面板( Accordion )进行面板扩展。所以我所尝试的是我只想在这样的一个父扩展面板中显示子面板。见下图。

enter image description here

数据库将成为顶级父面板,在它内部我有不同的数据库作为子面板。为此,我编写了这样的代码。但是代码不起作用意味着当我单击子面板内的任何父面板时,一切都会折叠起来。我的意思是说面板正在崩溃。
见下面的代码:

<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>

我的计划是只显示那个特定的面板。这很奇怪,它对我不起作用。如果我将扩展面板放在单独的面板中,那么为我工作。有人可以建议我吗?

最佳答案

从今天开始,你可以。 see this stackblitz

 <!-- 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>

关于带子扩展面板的 Angular Material 扩展面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51499631/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com