У меня есть компонент:
export class PhotoComponent implements OnInit {
constructor(private foo:Foo[]) {
console.log(this.foo);
}
}
Я пытаюсь динамически визуализировать этот компонент в родительском компоненте, как показано ниже:
export class AlbumComponent implements OnInit {
//_ctr definition and other not relevant code
dynamicComponent:any = PhotoComponent
injector:any = createInjector(this.foolist);
createInjector(foolist) {
let injector = Injector.create([
{ provide: Foo, useClass: Foo, useValue: foolist, multi:true}
], this.injector);
return injector;
}
}
и в album.component. html:
<ng-container *ngComponentOutlet="dynamicComponent;injector:injector"> </ng-container>
все это работает, если Foo
не массив. Так как мне ввести массив?