i like the idea but there isn’t an easy way to update this from a child controller. I thought about adding a helper function that the child controller could call but this doesn’t appear to be exposed in JS for me to set it on the sideMenu.
This was added to a helper function that I called in the needed controllers to disable it. The functions that need it enabled call a helper function that sets it to true:
@andytjoslin So maybe I missing something but if I didn’t want to give users an option and just hardcode the ability to drag in my controller would I just add the the attribute :
drag-content="canDragContent"
To my side-menu-content then in my controller set that to false:
$scope.canDragContent = false;
Is this correct or is there more too it because I couldn’t get it to work.
This solution didn’t really work for me either. The reason being is I need/want to set the ability to drag in a views controller via $scope.sideMenuController.
Would be nice if drag-content was exposed there so it could be set from anywhere.
Side note: @mhartington i couldn’t help but notice the similarities in our avatars, lol
Agreed. What I’ve done now is creating multiple views that have their own headers and one that has the side menu setup, but there is a visible transition between the different views. Not optimal but it works until a global feature is created. Seems like a lot of people are wanting to have config features for each directive accessible via their controllers.
in my 4th post (5th one of the thread) I found a solution by using this setup. I put it into a helper method i have for my app:
var appHelpers = {
disableNavMenu: function($scope) {
// disable nav from being draggable
angular.element(document.querySelector('#nav-menu-pane')).scope().dragContent = false;
}
};
Then in any controller I just call appHelpers.disableNavMenu($scope);. I was just trying to use that helper to instead change the dragContent that is on the $scope without having to query for it.
So I can put this in the controllers where I want to disable the side menu drag and then leave it out when I want to enable it again? Do you have a demo of this?
The problem is you have a scope (PageCtrl) that is a child scope of the side-menu-content scope. So if you just set a boolean on the child scope, it won’t get set on the parent scope.
The best way to have something that will properly inherit is:
Put a boolean on rootScope, and set that
Setup a function on the side-menu-content and call that.