Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angular 6:在动态创建组件的第二次初始化后,无法读取未定义的属性_Javascript_Angular_Angular6_Angular Components_Angular Dynamic Components - Fatal编程技术网

Javascript Angular 6:在动态创建组件的第二次初始化后,无法读取未定义的属性

Javascript Angular 6:在动态创建组件的第二次初始化后,无法读取未定义的属性,javascript,angular,angular6,angular-components,angular-dynamic-components,Javascript,Angular,Angular6,Angular Components,Angular Dynamic Components,我试图动态创建一个组件,该组件有一个要初始化的模型类 这是我面临的问题: 当我创建组件一次,然后第二次尝试时,它会出现问题 以下是我的代码: onClose() { this.thisComponentRef.destroy(); } /* Please be noted, ElCategoriesEditComponent is a parent component of ElSubGeneralBodyEditComponent */ .HTML <div [formGrou

我试图动态创建一个组件,该组件有一个要初始化的模型类

这是我面临的问题:

当我创建组件一次,然后第二次尝试时,它会出现问题

以下是我的代码:

onClose() {
  this.thisComponentRef.destroy();
}

/* Please be noted, ElCategoriesEditComponent is a parent component of ElSubGeneralBodyEditComponent */
.HTML

<div [formGroup]="articleCategoryGeneralBodyEditForm">
 <input type="hidden" formControlName="category_details_language_id" [(ngModel)]="article_category_detail.category_details_language_id">
 <div class="row">
  <div class="col-sm-12">
   <div class="form-group">
    <label for="category_details_name"><strong class="form-control-required">*</strong> Category Name</label>
    <input type="text" class="form-control" id="category_details_name" placeholder="Enter category name | ex: Parent" formControlName="category_details_name" [(ngModel)]="article_category_detail.category_details_name">
   </div>
  </div>
 </div>
</div>
这就是我动态创建组件的方式:

createEditFormComponent() {

this.editFormContainerRef.clear();
const factory: ComponentFactory<any> = this.resolver.resolveComponentFactory(ElCategoriesEditComponent);
this.componentRef = this.editFormContainerRef.createComponent(factory);
this.componentRef.instance.thisComponentRef = this.componentRef;
}
我对其他组件也做了同样的操作,它们工作正常,只是其他组件与此组件(ElCategoriesEditComponent)的不同之处在于此组件有一个子组件。

我知道很难描述像这样的问题,或者我不能说得更清楚,如果你需要更多信息,请问我

任何帮助都会在很长一段时间内救我


提前谢谢

检查中的语法错误question@PrashantPimpale我把注释注释注释掉了,现在请告诉我你的语法错误在哪里。前面缺少引号ngmodel@Simon_Weaver谢谢你的指点!你能试试文章类别详细信息吗?.category\u details\u language\u id而不是文章类别详细信息。category\u details\u language\u id
onClose() {
  this.thisComponentRef.destroy();
}

/* Please be noted, ElCategoriesEditComponent is a parent component of ElSubGeneralBodyEditComponent */