I have a basic clarity angular template with search in sidenav. When I click find button in sidenav on mobile device, sidenav does not disappear. How I can close sidenav using angular?
Asked
Active
Viewed 823 times
3
-
Can you share how you've created your template? – Jeremy Wilken Sep 19 '17 at 15:29
-
Yes, sure
1 Answers
5
The most straightforward solution would be for you to get a reference to the NavLevelDirective
instance for the sidenav with @ViewChild
, and all its close()
method.
For instance, add a reference variable in your template:
<nav #mySidenav class="sidenav" [clr-nav-level]="2">
<app-sidebar></app-sidebar>
</nav>
Then access it in your app's component by using:
@ViewChild("mySidenav", {read: NavLevelDirective}) sidenav: NavLevelDirective;
and just call sidenav.close()
when the user clicks the "find" button.

Eudes
- 1,521
- 9
- 17