gpt4 book ai didi

javascript - $window.location 不会重新加载页面,Angular

转载 作者:行者123 更新时间:2023-11-30 08:26:02 26 4
gpt4 key购买 nike

我正在尝试重新加载我的管理页面,我知道 Angular 有 $window.location.reload()$route.reload()。我尝试通过将 $window 注入(inject)函数的参数来使用 $window.location.reload()

scope.uploadList = function($window) { 
//...
$window.location.href = /#/admin';
}

在成功闪现消息下方,但我仍然收到一条错误消息

Cannot read property `location` of `undefined`.

不知道从这里去哪里。我已将其添加到指令中。

最佳答案

您需要将 $window 注入(inject)到 Controller 中而不是方法中,它会起作用。

关于javascript - $window.location 不会重新加载页面,Angular,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45513979/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com