如何更改 NgbCollapse 默认值 false?
How to change NgbCollapse default value of false?
ngbCollapse 的默认值为 false,如 https://ng-bootstrap.github.io/#/components/collapse. The example given there uses the following code: https://ng-bootstrap.github.io/app/components/collapse/demos/basic/plnkr.html
所述
<p>
<button type="button" class="btn btn-outline-primary" (click)="isCollapsed = !isCollapsed"
[attr.aria-expanded]="!isCollapsed" aria-controls="collapseExample">
Toggle
</button>
</p>
<div id="collapseExample" [ngbCollapse]="isCollapsed">
<div class="card">
<div class="card-block">
You can collapse this card by clicking Toggle
</div>
</div>
</div>
如何覆盖默认设置以使工具栏默认折叠?
注意到了同样的事情。在构造函数中初始化变量,它工作正常。
export class AppComponent {
isCollapsed:boolean;
constructor() {
this.isCollapsed = true;
}
在 Typescript 中修改它似乎偏离了使用模块提供的属性的意图。相反,通过利用 [ngbCollapse]
,您不需要添加到 Typescript,并且可以利用 ngDirectives 的优势进行更多控制。
<div id="collapseExample" [ngbCollapse]="!isCollapsed">
此外,当在动态生成的内容 (*ngFor...[ngbCollapse]=
) 中使用时,您可以利用 ng-if-else 条件状态
*ngIf="getIsEditing(buffer); then tableEdit; else tableView;"
ngbCollapse 的默认值为 false,如 https://ng-bootstrap.github.io/#/components/collapse. The example given there uses the following code: https://ng-bootstrap.github.io/app/components/collapse/demos/basic/plnkr.html
所述<p>
<button type="button" class="btn btn-outline-primary" (click)="isCollapsed = !isCollapsed"
[attr.aria-expanded]="!isCollapsed" aria-controls="collapseExample">
Toggle
</button>
</p>
<div id="collapseExample" [ngbCollapse]="isCollapsed">
<div class="card">
<div class="card-block">
You can collapse this card by clicking Toggle
</div>
</div>
</div>
如何覆盖默认设置以使工具栏默认折叠?
注意到了同样的事情。在构造函数中初始化变量,它工作正常。
export class AppComponent {
isCollapsed:boolean;
constructor() {
this.isCollapsed = true;
}
在 Typescript 中修改它似乎偏离了使用模块提供的属性的意图。相反,通过利用 [ngbCollapse]
,您不需要添加到 Typescript,并且可以利用 ngDirectives 的优势进行更多控制。
<div id="collapseExample" [ngbCollapse]="!isCollapsed">
此外,当在动态生成的内容 (*ngFor...[ngbCollapse]=
) 中使用时,您可以利用 ng-if-else 条件状态
*ngIf="getIsEditing(buffer); then tableEdit; else tableView;"