forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenuClose.js
More file actions
43 lines (43 loc) · 1.45 KB
/
Copy pathmenuClose.js
File metadata and controls
43 lines (43 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @ngdoc directive
* @name menuClose
* @module ionic
* @restrict AC
*
* @description
* `menu-close` is an attribute directive that closes a currently opened side menu.
* Note that by default, navigation transitions will not animate between views when
* the menu is open. Additionally, this directive will reset the entering view's
* history stack, making the new page the root of the history stack. This is done
* to replicate the user experience seen in most side menu implementations, which is
* to not show the back button at the root of the stack and show only the
* menu button. We recommend that you also use the `enable-menu-with-back-views="false"`
* {@link ionic.directive:ionSideMenus} attribute when using the menuClose directive.
*
* @usage
* Below is an example of a link within a side menu. Tapping this link would
* automatically close the currently opened menu.
*
* ```html
* <a menu-close href="#/home" class="item">Home</a>
* ```
*/
IonicModule
.directive('menuClose', ['$ionicHistory', function($ionicHistory) {
return {
restrict: 'AC',
link: function($scope, $element) {
$element.bind('click', function() {
var sideMenuCtrl = $element.inheritedData('$ionSideMenusController');
if (sideMenuCtrl) {
$ionicHistory.nextViewOptions({
historyRoot: true,
disableAnimate: true,
expire: 300
});
sideMenuCtrl.close();
}
});
}
};
}]);