mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
When navigating to a view from a button/link with the `menuClose` attribute directive, the back button should not show for the next view.
38 lines
1.1 KiB
JavaScript
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();
|
|
}
|
|
});
|
|
}
|
|
};
|
|
}]);
|