I’ve just tried updating my app to 0.9.25 (well, technically a couple commits after it, 02365e0fe35780e5629d44dea65dc51ceae2a075). To open the side menu, I’d made a directive:
.directive('openMenu', ['$ionicGesture', '$rootScope', function($ionicGesture, $rootScope) {
return {
restrict: 'A',
link: function ($scope, $element, $attrs) {
var handleTap = function (e) {
//console.log('openMenu');
e.preventDefault();
if ($rootScope.sideMenuController) {
$rootScope.sideMenuController.toggleLeft();
}
};
var tapGesture = $ionicGesture.on('tap', handleTap, $element);
$scope.$on('$destroy', function () {
// Clean up - unbind drag gesture handler
$ionicGesture.off(tapGesture, 'tap', handleTap);
});
}
};
}])
When it calls the toggle on the side menu controller, I get the following error:
I’m not sure what your goal is, but it looks like you’re doing it the hard way.
You can assign an ng-click directive to whatever element you want to use to open the menu (like <a ng-click="open_menu">Menu</a>, and then in your controller add a scope function to do the opening:
And I know ng-click can be registered, I was trying to make a directive at one point to make it easier to work around tap-through issue I was hitting. May not be necessary anymore but step one was just getting things updated to the latest version, since the release notes make me think you might have fixed my issue.
Yup, that worked, thanks @mhartington. I have to say, the ion- prefixes make sense for tags, but it makes it really confusing when upgrading my code that some attributes have ion- in front of them also, and some don’t. “Well, I need to add ion- to the side-menu-content= attribute, but not to the side= attribute on the ion-side-menu tag” and so on.
@RangerRick I think they said in the announcement that they will be updating the documents to reflect this change once this version is released so expect the docs to be a little behind. The best place for up to date references is the ionic codepen page.
As far as some directives getting the ion- prefix and some not, I think that just maybe some confusion. The directives themselves are getting the prefix and the available options for the particular directive do not. Maybe making the directive’s options prefixed could help with the confusion, but it does seem a bit verbose in my opinion.
Yeah, I understand that it’s a directive/option thing, it’s just a bit confusing when you’re mixing an attribute directive into another tag directive. In the long run, no one will have written it the old way and it won’t seem weird, I suppose, but just looking at the HTML I have to write, it feels very arbitrary even if there’s a reasonable technical reason for it.
Way down on the priority list, just thought I’d mention it. Might end up being confusing for n00bs.