Topic: Angular Collapase | Start with it open?
Bill Bensing pro asked 6 years ago
Is there a way to start with it the Collapse open? I tried the following with no success:
@ViewChild('Collapse') public Collapse: CollapseDirective; ngOnInit(){ this.Collapse.show(); // attempt 1 this.Collapse.toggle(); // attempt 2 this.Collapse.isCollapsed = false; }
Arkadiusz Idzikowski staff answered 6 years ago
mr.Jelle-Beat free answered 6 years ago
<div [mdbCollapse]="isCollapsed" #divId="bs-collapse" ></div>TS:
import {AfterViewInit, Component, ViewChildren} from '@angular/core'; import {CollapseDirective} from 'ng-uikit-pro-standard'; @ViewChildren(CollapseDirective) collapses: CollapseDirective[]; ngAfterViewInit() { this.collapses.forEach((collapse: CollapseDirective) => { collapse.show(); }); }
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- ForumUser: Pro
- Premium support: No
- Technology: MDB Angular
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No
Dharmen Milestone free commented 6 years ago
use ngAfterViewInit lifecycle hook