简体   繁体   English

关闭引导程序模式后退按钮引导程序。

[英]Close bootstrap modal back button bootstrap./

I am building an angularjs app and i am using bootstrap modal. 我正在构建一个angularjs应用程序,并且正在使用引导模态。

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 # 我使用html5mode为off表示我有#

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. 我试图在用户打开模态后添加history.pushstate(null,null,'modalopened'),然后在模态关闭或用户单击后退按钮并向后导航时将其删除。

I understand that the back button on mobile phones will autoamtically move back in the history api. 我了解到,手机上的后退按钮会自动在历史记录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. 当用户单击“后退”按钮时,将触发$ locationChangeStart,您可以附加到事件并执行自定义隐藏逻辑。

$scope.$on('$locationChangeStart', function(event, newUrl, oldUrl) {

      //hide the control

    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM