描述如題,求大神指點(diǎn)代碼父組件html:<ng-container *ngComponentOutlet="switchComponent"></ng-container>ts:public switchComponent = null;constructor() {this.switchComponent = PatientRecordComponent;}子組件<div *ngif="false">ssss</div>嘗試解決方法父組件html:<ng-container *ngComponentOutlet="switchComponent; ngModuleFactory: myModule;"></ng-container>ts:import {NgModuleFactory, Compiler} from '@angular/core';import {PatientRecord} from '../common/patient/record/record.module';public switchComponent = null;myModule: NgModuleFactory<any>;constructor(compiler: Compiler) {this.myModule = compiler.compileModuleSync(PatientRecord);
this.switchComponent = PatientRecordComponent;}
angular5.2 用ngComponentOutlet 添加的組件沒有bind ngif?
明月笑刀無情
2019-03-14 18:15:39