I am building an angularjs app and i am using bootstrap modal.
Once the user hits the back button on his phone, i want to have him close the modal.
I am using html5mode as off meaning i have the #
I am trying to add history.pushstate(null,null,'modalopened') once the user opens the modal then remove it once the modal closes or the user clicks the back button and navigates backwards.
I understand that the back button on mobile phones will autoamtically move back in the history api.
however when i do that i get redirected back to the root '/#/'
$locationChangeStart fires when user clicks back button, you can attach to the event and do your custom logic of hiding.
$scope.$on('$locationChangeStart', function(event, newUrl, oldUrl) {
//hide the control
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.