Javascript 实例化BS模式的非法调用
我试图通过组件调用angular中的引导模式,而不是使用它的HTML属性。我得到一个错误(即非法调用) 组成部分:Javascript 实例化BS模式的非法调用,javascript,angular,typescript,twitter-bootstrap,Javascript,Angular,Typescript,Twitter Bootstrap,我试图通过组件调用angular中的引导模式,而不是使用它的HTML属性。我得到一个错误(即非法调用) 组成部分: @ViewChild('myModal') div:any; ngAfterViewInit() {let bs = new bootstrap.Modal(this.div);} HTML 。。。 您需要使用该服务,而不是创建它的实例。对代码进行以下更改: import {NgbModal, ModalDismissReasons} from '@ng-bootstrap/n
@ViewChild('myModal') div:any;
ngAfterViewInit() {let bs = new bootstrap.Modal(this.div);}
HTML
。。。
您需要使用该服务,而不是创建它的实例。对代码进行以下更改:
import {NgbModal, ModalDismissReasons} from '@ng-bootstrap/ng-bootstrap';
...
...
@ViewChild('myModal') div:any;
constructor(private modalService: NgbModal )
ngAfterViewInit() {
// make sure you get the instance of the child.
this.modalService.open(this.div);
}
import {NgbModal, ModalDismissReasons} from '@ng-bootstrap/ng-bootstrap';
...
...
@ViewChild('myModal') div:any;
constructor(private modalService: NgbModal )
ngAfterViewInit() {
// make sure you get the instance of the child.
this.modalService.open(this.div);
}