在我的 Excel JavaScript 插件中,我使用 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());
});
})
})
关于javascript - $location.path 在弹出浏览器窗口中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42779534/