关闭bootstrap模态后退按钮bootstrap./

时间:2022-05-16 19:39:33

I am building an angularjs app and i am using bootstrap modal.

我正在构建一个angularjs应用程序,我正在使用bootstrap模式。

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作为关闭意味着我有#

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 '/#/'

然而,当我这样做时,我被重定向回根'/#/'

1 个解决方案

#1


0  

$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

    }

#1


0  

$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

    }