繁体   English   中英

当用户在angular js中确认时如何移动到下一条路线

[英]How to move to next route when user confirms in angular js

我已经使用jquery插件实现了自定义确认框警报。 我的要求是,当用户确认他的选项时(即他单击确认框中的“是”按钮),他应该转到他选择的路线。 如果他单击否,那么他应该保留在同一页面上。

  /*location change logic*/
$scope.$on('$locationChangeStart', function (event, nextUrl) {

    if (checkAllInputFields()) {

        event.preventDefault();
        bootbox.confirm("Are you sure?", function(result) {
            if (result) {
                console.log("User confirmed dialog");
                $location.path(newUrl);  //this does not work
               //i get the console but the user does not go to the selected route
            } else {

                console.log("User declined dialog");
            }
        });

    }
});

由于某些原因,即使用户单击确认框中的“确定”按钮,他也不会被重定向到他选择的路由。

有人可以帮助解决此问题吗?

尝试使用$location模块。 将模块注入您的控制器,并确认设置$location.path(your path here)

看AngularJS文档脱颖而出的更多信息: 文档

暂无
暂无

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

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