$ location.Path在弹出式浏览器窗口中不起作用



在我的javascript addin for excel中,我使用 window.open("https://localhost:3000/#/posts/editor/", "popup", "width=1000, height=1100")弹出浏览器窗口。

我意识到,与普通浏览器不同,我们无法在此弹出式浏览器窗口中手动修改URL。

此页面由angularjs构建,我在此页面中有一个保存按钮,它链接到以下功能:

$scope.save = function () {
    posts.create({ title: "newCreated", link: "" })
        .success(function (post) {
            $location.path("/posts/editor/" + post._id)
        })
})

我意识到$location.path不会在此弹出窗口中重定向页面。而在普通浏览器中,$location.path可以工作。

有人知道是否可以解锁弹出式浏览器窗口以使$location.path工作?

尝试$rootScope.$apply$scope.$apply()

$scope.save = function () {
    posts.create({ title: "newCreated", link: "" })
        .success(function (post) {
           $rootScope.$apply(function() {
            $location.path("/posts/editor/" + post._id)
            console.log($location.path());
          });
        })
})

最新更新