构建StaticInjectorError时出现Angular 7

问题描述 投票:0回答:1

我能够在开发服务器中构建和服务应用程序。但是,在进入生产构建时,该应用程序导致以下错误。

任何建议都会有所帮助。在此先感谢您。如果有其他信息,请告诉我。

角度版本-7.2.3

main.272e7817336e789a3feb.js:1错误错误:StaticInjectorError [e-> e]:StaticInjectorError(平台:核心)[e-> e]:NullInjectorError:没有e的提供者!在e.get(main.272e7817336e789a3feb.js:1)在main.272e7817336e789a3feb.js:1在e(main.272e7817336e789a3feb.js:1)在e.get(main.272e7817336e789a3feb.js:1)在main.272e7817336e789a3feb.js:1在e(main.272e7817336e789a3feb.js:1)在e.get(main.272e7817336e789a3feb.js:1)在Pg(main.272e7817336e789a3feb.js:1)在main.272e7817336e789a3feb.js:1在Ig(main.272e7817336e789a3feb.js:1)

node.js angular angular-material angular-ui-router
1个回答
0
投票

就是说您已经将服务直接注入到组件的构造函数中。您需要先在模块中添加服务,而不是直接注入组件。

将其添加到模块的提供者数组中。然后,您可以在组件中使用它。

Ex:提供者:[ServiceName]

© www.soinside.com 2019 - 2024. All rights reserved.