【发布时间】:2017-03-04 21:07:57
【问题描述】:
我在应用程序中使用组件而不是模板打开模态然后我需要将对象模型传递给模态组件,问题是打字稿给出了 modalRef.componentInstance not exists as property 的错误,我完全复制了示例表单演示页面但再次给出相同的错误,并且永远不会在模态内容类上填充@input 变量,
这是错误 无法设置未定义的属性“模型”
@Component({
selector: 'company-list',
templateUrl: './app/components/company/company-list.component.html'
})
export class CompanyListComponent implements {
private modalRes: Company;
constructor(private modalService: NgbModal) {
}
open(company: Company) {
const modalRef = this.modalService.open(CompanyAddComponent);
modalRef.componentInstance.name = 'some name'; //** this line gives error
modalRef.result.then((result) => {
}, (reason) => {
});
}
createCompany(model: Company) {
this.companyService.createCompany(model);
}
}
在模态中我声明了这个变量来获取传入的值 @Input() 模型:公司; 但它始终为空
【问题讨论】:
标签: angular typescript modal-dialog ng-bootstrap