-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(modal): provide
NgbModal
at the correct level (#4464)
Provides `NgbModal` at the `NgbModalModule` level as well as at the 'root' level. Provides environment injector based on the `contentInjector` and not the `appRef.injector` when using component as modal content. Fixes #4447
- Loading branch information
1 parent
7f2146d
commit 8ac01c2
Showing
4 changed files
with
93 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Component, inject, Injectable, NgModule, OnDestroy } from '@angular/core'; | ||
import { NgbModal } from './modal'; | ||
import { NgbModalModule } from './modal.module'; | ||
import { RouterModule } from '@angular/router'; | ||
|
||
@Injectable() | ||
class LazyService { | ||
get text() { | ||
return 'lazy modal'; | ||
} | ||
} | ||
|
||
@Component({ template: '{{ lazyService.text }}' }) | ||
class LazyModalContent { | ||
constructor(public lazyService: LazyService) {} | ||
} | ||
|
||
@Component({ template: 'child' }) | ||
class LazyComponent implements OnDestroy { | ||
private _ref = inject(NgbModal).open(LazyModalContent); | ||
|
||
ngOnDestroy() { | ||
this._ref.close(); | ||
} | ||
} | ||
|
||
@NgModule({ | ||
declarations: [LazyComponent, LazyModalContent], | ||
providers: [LazyService], | ||
imports: [ | ||
NgbModalModule, | ||
RouterModule.forChild([ | ||
{ | ||
path: '', | ||
component: LazyComponent, | ||
}, | ||
]), | ||
], | ||
}) | ||
export default class LazyModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { NgbModal } from './modal'; | ||
|
||
export { NgbModal } from './modal'; | ||
export { NgbModalConfig, NgbModalOptions } from './modal-config'; | ||
export { NgbModalRef, NgbActiveModal } from './modal-ref'; | ||
export { ModalDismissReasons } from './modal-dismiss-reasons'; | ||
|
||
@NgModule({}) | ||
@NgModule({ providers: [NgbModal] }) | ||
export class NgbModalModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters