mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
41 lines
949 B
JavaScript
41 lines
949 B
JavaScript
/**
|
|
* @ngdoc directive
|
|
* @name menuToggle
|
|
* @module ionic
|
|
* @restrict AC
|
|
*
|
|
* @description
|
|
* Toggle a side menu on the given side
|
|
*
|
|
* @usage
|
|
* Below is an example of a link within a nav bar. Tapping this link would
|
|
* automatically open the given side menu
|
|
*
|
|
* ```html
|
|
* <ion-view>
|
|
* <ion-nav-buttons side="left">
|
|
* <button menu-toggle="left" class="button button-icon icon ion-navicon"></button>
|
|
* </ion-nav-buttons>
|
|
* ...
|
|
* </ion-view>
|
|
* ```
|
|
*/
|
|
IonicModule
|
|
.directive('menuToggle', ['$ionicViewService', function($ionicViewService) {
|
|
return {
|
|
restrict: 'AC',
|
|
require: '^ionSideMenus',
|
|
link: function($scope, $element, $attr, sideMenuCtrl) {
|
|
var side = $attr.menuToggle || 'left';
|
|
$element.bind('click', function(){
|
|
if(side === 'left') {
|
|
sideMenuCtrl.toggleLeft();
|
|
} else if(side === 'right') {
|
|
sideMenuCtrl.toggleRight();
|
|
}
|
|
});
|
|
}
|
|
};
|
|
}])
|
|
|