Angular 角度BSModal-编辑项目期间无法传递数据

Angular 角度BSModal-编辑项目期间无法传递数据,angular,Angular,我想在BSModal中传递一个id。下面是我在.ts文件中的模式打开代码: import { BsModalService } from 'ngx-bootstrap/modal'; import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; ... ... openModalEdit(template: TemplateRef<any>) { this.modalRef = this.modalS

我想在BSModal中传递一个id。下面是我在
.ts
文件中的模式打开代码:

import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
...
...
openModalEdit(template: TemplateRef<any>) {
  this.modalRef = this.modalService.show(
    template,
    Object.assign({ignoreBackdropClick:true, keyboard:false, class: 'gray modal-lg'})
    );
  this.modalRef.content.id = 220;
  console.log("Open Modal event")
}
在模式中的
.html
文件中,我有以下代码:

export class EditGenreComponent implements OnInit {
  public id: any;
  ...
}
<label class="required">Genre {{id}}</label>
Genre{{id}
它显示控制台中的错误

无法将属性“id”设置为null

此外,在模式中,我看到以下内容:

类型[对象]


在角度模式中,当模式出现时,可以将数据作为对象传递。例如:

HTML:

<div>
  <button (click)="show()">Show</button>
</div>
<div>
  <button (click)="show()">Show</button>
</div>
  show() {
    const initialState = {
        user: "Guest"
      };
    this.modalRef = this.modalService.show(ShowComponent,{initialState});
  }