Topic: INSTANCIAR SIDENAV MDB5 CON TYPESCRIPT
how to instantiate mdb5 sidenav with typescript, to be able to use its methods from typescript?
Arkadiusz Idzikowski staff answered 4 years ago
You need to use Angular template reference variable (for example #sidenav
) on the sidenav HTML element. This is example code from our documentation:
<mdb-sidenav #sidenav="mdbSidenav">
Then in TS file use ViewChild
decorator to get access to the component and its methods. If you want to use method on component init, it will be available in ngAfterViewInit
hook:
@ViewChild('sidenav') sidenav: MdbSidenavComponent;
ngAfterViewInit(): void {
this.sidenav.show();
}
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- User: Pro
- Premium support: Yes
- Technology: MDB Angular
- MDB Version: 11.0.0
- Device: Laptop
- Browser: Google Chrome
- OS: Windows 10
- Provided sample code: No
- Provided link: No