Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Sidenav : Is there a way to call a callback on escape or backdrop close ? #3179

Closed
mfilotto opened this issue Jun 9, 2015 · 11 comments
Closed
Labels
has: Pull Request A PR has been created to address this issue type: enhancement

Comments

@mfilotto
Copy link

mfilotto commented Jun 9, 2015

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

@sylviefiat
Copy link

+1
Any idea ?

@ThomasBurleson ThomasBurleson self-assigned this Jul 6, 2015
@ThomasBurleson ThomasBurleson modified the milestone: Backlog Jul 6, 2015
@jameswyse
Copy link

👍 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 :/

@sylviefiat
Copy link

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);

@jameswyse
Copy link

Thanks for the workaround @sylviefiat!

@george3447
Copy link

+1

@ThomasBurleson ThomasBurleson modified the milestones: 1.0-beta1, Backlog Aug 6, 2015
@naomiblack naomiblack modified the milestones: 1.0-beta1, 0.12.0 Aug 14, 2015
@ThomasBurleson ThomasBurleson modified the milestones: 0.12, 0.13 Oct 15, 2015
@ThomasBurleson ThomasBurleson modified the milestones: 1.0-rc2, 1.0-rc3, 1.0-rc4 Oct 30, 2015
@ThomasBurleson ThomasBurleson modified the milestones: 1.0-rc4, 1.0-rc5 Nov 16, 2015
EladBezalel added a commit that referenced this issue Dec 2, 2015
Added onClose callback to handle close, backdrop click or escape key pressed

fixes #3179
@ThomsCass
Copy link

Or

$scope.$watch(
            function() { return $mdSidenav('yourSide').isOpen(); },
            function(newValue, oldValue) {
                console.log(newValue);
            }
        );

@ThomasBurleson ThomasBurleson modified the milestones: 1.0-rc8, 1.1.0, Backlog Jan 5, 2016
EladBezalel added a commit that referenced this issue Jan 29, 2016
Added onClose callback to handle close, backdrop click or escape key pressed

fixes #3179
@mathiasmoeller
Copy link

+1

@mfilotto
Copy link
Author

@EladBezalel Hi any update on this one ?

@EladBezalel
Copy link
Member

@mfilotto waiting for merge .. :)

EladBezalel added a commit that referenced this issue Feb 26, 2016
Added onClose callback to handle close, backdrop click or escape key pressed

fixes #3179
@EladBezalel EladBezalel modified the milestones: 1.3.0, Backlog Apr 18, 2016
@ThomasBurleson ThomasBurleson modified the milestones: 1.3.0, Backlog Apr 20, 2016
@ThomasBurleson ThomasBurleson added has: Pull Request A PR has been created to address this issue and removed pr: merge ready This PR is ready for a caretaker to review labels Apr 21, 2016
@jrcollins4
Copy link

+1

EladBezalel added a commit that referenced this issue Jun 20, 2016
Added onClose callback to handle close, backdrop click or escape key pressed

fixes #3179
toshiakiezaki pushed a commit to toshiakiezaki/angular-material that referenced this issue Jul 1, 2016
Added onClose callback to handle close, backdrop click or escape key pressed

fixes angular#3179

Closes angular#5974
@shivalthaker
Copy link

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)

@Splaktar Splaktar removed this from the - Backlog milestone Feb 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has: Pull Request A PR has been created to address this issue type: enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.