【发布时间】:2017-10-15 03:40:57
【问题描述】:
如何获得角度 2 中的元素? 如果我在 html 中有这个
<ng-template #content let-c="close" let-d="dismiss">
<div class="modal-header">Header</div>
<div class="modal-body">Body</div>
<div class="modal-footer">footer</div>
</ng-template>
我将它用于 ngBmodal ng-bootstrap 如果我使用按钮打开内容,它的工作 = 按钮
(click)="open(content,data.id)"
然后我想从组件中打开内容 在这种情况下,我会从其他页面重定向并打开内容
ngOnInit() {
this.activatedRoute.queryParams.subscribe((params: Params) => {
let id = params['id'];
if(id != undefined){
this.open('content',id);
}
});
}
open(content, id) {
this.dataModal = {};
this.getDataModal(id);
this.mr = this.modalService.open(content, { size: 'lg' });
}
模态打开但不使用 html,我尝试 afterviewinit 获取 #content 它不起作用 谢谢,对不起我的英语:v
【问题讨论】:
-
你找到解决方案了吗?
标签: angular2-template angular2-directives ng-bootstrap