Skip to content
This repository was archived by the owner on Jan 22, 2018. It is now read-only.

Commit 3ad7786

Browse files
author
Kamil Kisiela
committed
feat(MenuLink): close on click
1 parent 112119d commit 3ad7786

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<md-button class="menu-link" ui-sref="demo.view({id: vm.sectionId})">
1+
<md-button class="menu-link" ui-sref="demo.view({id: vm.sectionId})" ng-click="vm.close()">
22
{{::vm.sectionName}}
33
</md-button>

demo/client/components/menu-link/menu-link.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Component, View } = angular2now;
1+
const { Component, View, Inject } = angular2now;
22

33
@Component({
44
selector: 'menu-link',
@@ -10,6 +10,17 @@ const { Component, View } = angular2now;
1010
@View({
1111
templateUrl: 'client/components/menu-link/menu-link.html'
1212
})
13+
@Inject(['$mdSidenav'])
1314
class MenuLinkComponent {
14-
15+
constructor($mdSidenav) {
16+
this.$mdSidenav = $mdSidenav;
17+
18+
this.componentId = 'left';
19+
}
20+
21+
close() {
22+
if (!this.$mdSidenav(this.componentId).isLockedOpen()) {
23+
this.$mdSidenav(this.componentId).close();
24+
}
25+
}
1526
}

0 commit comments

Comments
 (0)