mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
chore(menuToggle): simplify
This commit is contained in:
17
js/angular/directive/menuToggle.js
vendored
17
js/angular/directive/menuToggle.js
vendored
@@ -5,11 +5,11 @@
|
||||
* @restrict AC
|
||||
*
|
||||
* @description
|
||||
* Toggle a side menu on the given side
|
||||
* 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
|
||||
* 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>
|
||||
@@ -21,20 +21,19 @@
|
||||
* ```
|
||||
*/
|
||||
IonicModule
|
||||
.directive('menuToggle', ['$ionicViewService', function($ionicViewService) {
|
||||
.directive('menuToggle', function() {
|
||||
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') {
|
||||
if ($attr.menuToggle === 'right') {
|
||||
sideMenuCtrl.toggleRight();
|
||||
} else {
|
||||
sideMenuCtrl.toggleLeft();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user