modal-Angular
unknown
typescript
a year ago
954 B
13
Indexable
import { Component, OnInit, ViewChild } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'app-modal-example',
template: `
<ng-template #content let-modal>
<div class="modal-header">
<h4 class="modal-title">Modal automático</h4>
<button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Este modal se muestra automáticamente al cargar la página.</p>
</div>
</ng-template>
`
})
export class ModalExampleComponent implements OnInit {
@ViewChild('content') content: any;
constructor(private modalService: NgbModal) {}
ngOnInit() {
this.openModal();
}
openModal() {
this.modalService.open(this.content, { ariaLabelledBy: 'modal-basic-title' });
}
}Editor is loading...
Leave a Comment