Files
ionic-framework/js/angular/directive/menuToggle.js
2014-10-09 20:35:08 -05:00

40 lines
885 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 button
* would open the given side menu, and tapping it again would close it.
*
* ```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', function() {
return {
restrict: 'AC',
require: '^ionSideMenus',
link: function($scope, $element, $attr, sideMenuCtrl) {
$element.bind('click', function(){
if ($attr.menuToggle === 'right') {
sideMenuCtrl.toggleRight();
} else {
sideMenuCtrl.toggleLeft();
}
});
}
};
});