I want to display a message in a modal using angular 4.0.0 and ng-bootstrap 1.0.0-beta.4 but it does not display the modal.
app-module.ts
@NgModule({
// ...
declarations: [
LoginComponent
],
imports: [
// ...
NgbModule.forRoot()
],
entryComponents: [LoginComponent],
})
export class AppModule { }
login.component.ts
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent {
@ViewChild('examplemodal')
private modalRef: TemplateRef<any>;
constructor(private modalService: NgbModal) { }
//.... some event that fires onModalRequest()
onModalRequest(): void {
const modalRef = this.modalService.open(this.modalRef); //Not working
modalRef.result.then((result) => {
console.log(result);
console.log('closed');
}).catch( (result) => {
console.log(result);
console.log('cancelling');
});
}
}
examplemodal.html
<ng-template #examplemodal>
<div class="modal">
stuff here...
</div>
</ng-template>
Any help please?
4.0.0-beta.3
). – Houseleek4.0.0-beta.2
. – Houseleek