Hi,
I have an ui-view in my sidenav and I'd like to reset the router path when the user click outside the sidenav (on the backdrop) or press escape.
Is there a way to do so ?
Thanks for your help
+1
Any idea ?
:+1: I need to save changes when the sidenav is closed and I don't see any way of doing that? Currently i'm using ngClick on the close icon - but it doesn't work for esc/backdrop close :/
Here is the workaround we use for now: You can use #974 and bind a function to your sidenav component in your controller
this.isOpen = function() { return false };
// Register bindnig function
$mdComponentRegistry
.when("yoursidenav")
.then( (sideNav)=>{
this.isOpen = angular.bind(sideNav, sideNav.isOpen );
});
And then add a watch on this function:
$scope.$watch("myController.isOpen()",(newValue,oldValue)=>{
// save your changes here
},true);
Thanks for the workaround @sylviefiat!
+1
Or
$scope.$watch(
function() { return $mdSidenav('yourSide').isOpen(); },
function(newValue, oldValue) {
console.log(newValue);
}
);
+1
@EladBezalel Hi any update on this one ?
@mfilotto waiting for merge .. :)
+1
Was just wondering, how can we use this fix when we want to capture whenever we click on backdrop or press esc key. I know how to use the $scope.$watch but still feel like using this fix somehow for the project. (y)
Most helpful comment
Or