I'm trying to implement a modal with ng2-bootstrap, but I got this error 'Error: ApplicationRef instance not found' and I don't know how can I fix it.
ng2-bootstrap, it said to add some hack, I tried to set it on app.component.ts but it doesn't work.
add-domain.component.html
<!-- Large modal -->
<button class="btn btn-primary" (click)="lgModal.show()">Large modal</button>
<div bsModal #lgModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" (click)="lgModal.hide()" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">Large modal</h4>
</div>
<div class="modal-body">
...
</div>
</div>
</div>
</div>
add-domain.component.ts
import { Component, ViewContainerRef } from '@angular/core';
@Component({
selector: 'add-domain',
templateUrl: 'add-domain.component.html',
})
export class AddDomainComponent {
private viewContainerRef: ViewContainerRef;
public constructor(viewContainerRef: ViewContainerRef) {
// You need this small hack in order to catch application root view container ref
this.viewContainerRef = viewContainerRef;
this.title = "Ajouter un domaine"
}
}
See their hack, you need to add viewContainerRef: