Angular 8:无法读取未定义的属性'runOutsideAngular' [英] Angular 8: Cannot read property 'runOutsideAngular' of undefined

查看:133
本文介绍了Angular 8:无法读取未定义的属性'runOutsideAngular'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在本地运行我的应用程序时,没有任何问题,但是当我托管应用程序(在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.

我尝试使用模板路由:

[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 并将目标更改为 es5 compilerOptions 下。

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 8:无法读取未定义的属性'runOutsideAngular'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆