Javascript $location.path在弹出的浏览器窗口中不起作用
在我的JavaScript Excel加载项中,我使用Javascript $location.path在弹出的浏览器窗口中不起作用,javascript,angularjs,google-chrome,popup,window,Javascript,Angularjs,Google Chrome,Popup,Window,在我的JavaScript Excel加载项中,我使用window.open(“https://localhost:3000/#/posts/editor/“,”弹出窗口“,”宽度=1000,高度=1100“弹出浏览器窗口 我意识到,与普通浏览器不同,我们无法手动修改此弹出浏览器窗口中的URL 此页面由angularjs构建,我在该页面中有一个保存按钮,它链接到以下功能: $scope.save = function () { posts.create({ title: "newCrea
window.open(“https://localhost:3000/#/posts/editor/“,”弹出窗口“,”宽度=1000,高度=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()
console中是否有错误?请尝试使用$scope。$apply()在console@KeshavI中没有错误。$apply(),我们可以在url栏中看到,新地址闪烁,然后恢复到
…posts/editor/
$scope。$apply()在设置路径后,在方法之外尝试此操作。、、。,,。。您也可以使用$state。是的。。你可以用它传递更多的值,甚至对象。你可以试试window.location吗?我意识到url“/posts/editor/”+post.\u id
无法在普通浏览器中加载,因为我的程序中有漏洞。我已经纠正了它们,现在,它可以通过$location.path
加载到普通浏览器和弹出窗口浏览器中。因此,即使url栏不可编辑,$location.path
也可以工作。感谢您的回答,很高兴知道像$state.go
和window.location
这样的备选方案。。。
$scope.save = function () {
posts.create({ title: "newCreated", link: "" })
.success(function (post) {
$rootScope.$apply(function() {
$location.path("/posts/editor/" + post._id)
console.log($location.path());
});
})
})