Modal - not open different modal child in same parent
See original GitHub issueI have created two different modal component end I have insert them in the same parent component, but when i click on the open button the same modl is opened (the first one).
my parent tempalte:
<div class="container">
<div class="btn-group btn-lg">
<app-accounting-modal [openButton]="modifyButton"></app-accounting-modal>
<app-accountingDelete-modal [openButton]="deleteButton"></app-accountingDeletmodal>
</div>
</div>
my first modal (app-accounting-modal) tempalte:
<ng-template #content let-c="close" let-d="dismiss">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div>{{Title}}</div>
<button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
</div>
</div>
</div>
</ng-template>
<button type="button" class="btn btn-default" (click)="open(content)">{{openButton}}</button>
<ng-template #content let-c="close" let-d="dismiss">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div>{{Title}}</div>
<button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
</div>
</div>
</div>
</ng-template>
<button type="button" class="btn btn-default" (click)="open(content)">{{openButton}}</button>
my second modal (app-accountingDelete-modal) template:
<ng-template #modal let-a="close" let-b="dismiss">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div>{{Title}}</div>
<button type="button" class="close" aria-label="Close" (click)="b('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Attenzione! Questo elemento {{accountingId}} verrà cancellato definitivamente</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" (click)="ok()">Ok</button>
<button type="button" class="btn btn-default" (click)="cancel()">Cancel</button>
</div>
</div>
</div>
</ng-template>
<button type="button" class="btn btn-default" (click)="open(modal)">{{openButton}}</button>
the code of twice modals is approximately the same:
@Component({
selector: 'app-accountingDelete-modal',
templateUrl: '../template/accounting-modal.component.html',
encapsulation: ViewEncapsulation.None,
providers: [NgbModal]
})
export class AccountingDeleteModal {
@Input() title: string;
@Input() accountingId: number;
@Input() openButton: string;
@Output() accountingDelete: EventEmitter<string> = new EventEmitter();
constructor(private modalService: NgbModal) {}
open(modal) {
console.log(modal)
this.modalService.open(modal);
}
... Other specifics methods
}
I have imported NgbModule.forRoot() in my app.module I had the same issue with two different datepicker in the same page;
angular: 4.1.3 ng-bootstrap: 1.0.0-alpha.26 Bootstrap 4.0.0-alpha.6
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to open modal for multiple components from same parent ...
Make sure that MyModalService should only be accessed from outside of the child components like parent component. Can't help without seeing your ...
Read more >Open Modal from Child Component
On each row of my child cmp i have a button where i want to open a modal. My problem is that the...
Read more >React Modal component - Material UI - MUI
Be a direct child descendent of the modal. Have an in prop. This corresponds to the open/close state. Call the onEnter callback prop...
Read more >JavaScript - Bootstrap
Multiple open modals not supported. Be sure not to open a modal while another is still visible. Showing more than one modal at...
Read more >Create a Popup Modal in React (with parent and ... - YouTube
Many tutorials create modals in the parent component, but in this tutorial I will show you how to create a Modal as a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i have same issue
@elainemarleyit How did you solved the problem? I have the same issue