Angular 8:无法读取未定义的属性“runOutsideAngular" [英] Angular 8: Cannot read property 'runOutsideAngular' of undefined
问题描述
当我在本地运行我的应用程序时,没有任何问题,但是当我尝试导航到某个页面时(在 firebase 托管上)托管应用程序时,我收到以下错误:无法读取未定义的属性runOutsideAngular"
.因为代码被缩小到 main.js 我似乎无法找到抛出错误的原因.当路由器应该导航到不同的页面时会抛出错误.
When i run my app locally there is no problem whatsoever, but when the app is hosted (on firebase hosting) whenever I try to navigate to a page I get the following error:
Cannot read property 'runOutsideAngular' of undefined
. Because the code is minified to main.js I can't seem to find why the error is thrown. The error is thrown when the router should navigate to a different page.
{
path: 'manage/:bookingid',
component: ManageBookingComponent
},
两个页面都使用 Angular 材质 Sidenav(将它们从页面中删除并不能解决错误).我发现了这个 StackOverflow 问题,但似乎没有任何答案工作.
Both pages use an Angular material Sidenav (removing them from the page doesn't resolve the error). I found this StackOverflow question, but none of the answers seem to work.
我尝试过使用模板路由:
I've tried using template routing:
[routerLink]="['/', 'manage', booking.id]"
和组件路由:
this.router.navigateByUrl(`/manage/${booking.id}`)
或
this.router.navigate(['/', 'manage', booking.id])
本地所有这些选项都有效,托管这是一个不同的故事..
locally all these options work, hosted this is a different story..
进一步研究可能表明这是 Angular Material 和 Router 之间的问题,请参阅此 SO 问题
further research may indicate it to be a issue between Angular Material and Router, see this SO question
推荐答案
这是 AoT 编译器的问题.由于 AoT,它发生在您的生产版本中.解决方法是转到 tsconfig.json
并将 target
更改为 compilerOptions
下的 es5
.
It is an issue with the AoT-compiler. It happens in your production builds because of AoT. A fix is to go to tsconfig.json
and change your target
to es5
under compilerOptions
.
我会先尝试修改您的 @angular-versions,因为 问题已关闭.一个>
I would try bumping your @angular-versions first, since the issue is closed.
这篇关于Angular 8:无法读取未定义的属性“runOutsideAngular"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!