Files
ionic-framework/js/angular/directive/menuClose.js
Adam Bradley ba3eefdf8a feat(menuClose): do not show next back button
When navigating to a view from a button/link with the `menuClose`
attribute directive, the back button should not show for the next view.
2014-11-12 12:30:11 -06:00

38 lines
1.1 KiB
JavaScript

/**
* @ngdoc directive
* @name menuClose
* @module ionic
* @restrict AC
*
* @description
* Closes a side menu which is currently opened. By default, navigation
* transitions will not animate between views when the menu is open and
* this directive is used to close the menu.
*
* @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', ['$ionicViewSwitcher', function($ionicViewSwitcher) {
return {
restrict: 'AC',
link: function($scope, $element, $attr) {
$element.bind('click', function() {
var sideMenuCtrl = $element.inheritedData('$ionSideMenusController');
if (sideMenuCtrl) {
// lower priority than navAnimation which allows navTransition
// to override this directive's nextTransition() call
$ionicViewSwitcher.nextTransition('none');
$ionicViewSwitcher.nextShowBack(false);
sideMenuCtrl.close();
}
});
}
};
}]);