Я создал компоненты библиотека с использованием углового клика ng generate library
, с компонентом, который использует *ngIf
внутри модуля.
После успешной сборки иустановить библиотеку в моем основном проекте, когда я пытаюсь использовать компонент, я получаю ошибку No provider for ViewContainerRef
.
Версии:
@ angular / cli версия: "~ 7.0.6",
@ angular / * версия: "~ 7.0.0"
Ошибка:
Ошибка ОШИБКИ: StaticInjectorError (AppModule) [NgIf -> ViewContainerRef]: StaticInjectorError(Платформа: ядро) [NgIf -> ViewContainerRef]: NullInjectorError: Нет поставщика для ViewContainerRef!
компонент:
import {Component, OnInit, Input} from '@angular/core';
@Component({
selector: 'al-card',
templateUrl: './card.component.html',
styleUrls: ['./card.component.scss']
})
export class CardComponent implements OnInit {
@Input() header: string;
@Input() text: string;
constructor() { }
ngOnInit() {
}
}
шаблон:
<div *ngIf="header">
</div>
модуль:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CardComponent } from './card.component';
@NgModule({
declarations: [CardComponent],
imports: [
CommonModule
],
exports: [CardComponent],
})
export class CardModule { }