chore(menuToggle): simplify

This commit is contained in:
Adam Bradley
2014-10-09 20:35:08 -05:00
parent b820b96092
commit 93d29af2d5

View File

@@ -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();
}
});
}
};
}]);
});