我有一个应用程序正在尝试升级到 Angular 5 和 Library-tize。我设置了 ng-packagr,因此构建并捆绑了 lib,这没有问题,直到我尝试将其中一个组件与 ngIf 或 ngFor 一起使用,这给了我错误
HeaderComponent.html:13 ERROR Error: StaticInjectorError[ViewContainerRef]:
StaticInjectorError[ViewContainerRef]:
NullInjectorError: No provider for ViewContainerRef!
at _NullInjector.get (core.js:993)
Run Code Online (Sandbox Code Playgroud)
在运行时。我环顾四周并尝试了一些不同的方法,但似乎没有什么可以解决它......
这是该库的相关模块代码。
@NgModule({
imports: [
CommonModule,
FormsModule,
RouterModule,
/* Bootstrap Imports */
AccordionModule,
AlertModule,
ButtonsModule,
CarouselModule,
CollapseModule,
BsDropdownModule,
ModalModule,
PaginationModule,
ProgressbarModule,
RatingModule,
TabsModule,
TimepickerModule,
TooltipModule,
TypeaheadModule,
DatepickerModule,
ServicesModule,
],
declarations: [
LayoutComponent,
HeaderComponent,
FooterComponent,
OffsidebarComponent,
SidebarComponent,
UserblockComponent,
OverlayComponent,
BusyIndicatorComponent
],
exports: [
LayoutComponent
],
providers: [
UserblockService
]
})
export class ComponentsModule {}
Run Code Online (Sandbox Code Playgroud)
这是报告错误的 HTML。
<a class="hidden-xs" trigger-resize="" (click)="toggleCollapsedSideabar()" *ngIf="!isCollapsedText()">
<i class="material-icons">menu</i>
</a>
Run Code Online (Sandbox Code Playgroud)
您应该将 BrowserModule 添加到您的导入数组中。
@NgModule({
imports: [
BrowserModule, <----- add this
CommonModule,
FormsModule,
RouterModule,
Run Code Online (Sandbox Code Playgroud)
更多信息请点击这里。
| 归档时间: |
|
| 查看次数: |
3470 次 |
| 最近记录: |