Topic: INSTANCIAR SIDENAV MDB5 CON TYPESCRIPT

llopezj priority asked 3 years ago


how to instantiate mdb5 sidenav with typescript, to be able to use its methods from typescript?


Arkadiusz Idzikowski staff answered 3 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();
}


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: Priority
  • 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