Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
angular-custom-modal
Advanced tools
Angular2+ Modal / Dialog (with inner component support).
A continuation of https://stackoverflow.com/a/46949848
zurfyx.github.io/angular-custom-modal
npm install angular-custom-modal
ngOnDestroy
(ed) when modal is closedapp.module.ts
imports: [
...
ModalModule,
...
],
...
})
app.component.html
<button (click)="htmlInsideModal.open()">Raw HTML inside modal</button>
<modal #htmlInsideModal>
<ng-template #modalHeader><h2>HTML inside modal</h2></ng-template>
<ng-template #modalBody>
<p>HTML content inside modal</p>
</ng-template>
</modal>
my-component.component.ts
@Component({
selector: 'app-my-component',
templateUrl: 'my-component.component.html',
})
export class AppModalContentComponent { }
my-component.component.html
<p>My component's HTML</p>
app.component.html
<button (click)="componentInsideModal.open()">Component inside modal</button>
<modal #componentInsideModal>
<ng-template #modalHeader><h2>Component inside modal</h2></ng-template>
<ng-template #modalBody>
<app-my-component></app-my-component>
</ng-template>
<ng-template #modalFooter></ng-template>
</modal>
See example source code for more information.
Why ng-template?
ng-template prevents the parent component from initializing the component. Only when the modal library finds it convenient the component will be initialize and visible to the user. Hence, it preserves the natural ngOnInit()
and ngOnDestroy()
that we expect.
Similar libraries which make use of <ng-content>
and its content transclution strategy, do not prevent the component from initializing, but rather just hide it. The component was already initialized in the parent component.
References:
https://angular.io/api/common/NgTemplateOutlet
https://blog.angular-university.io/angular-ng-template-ng-container-ngtemplateoutlet/
https://medium.com/claritydesignsystem/ng-content-the-hidden-docs-96a29d70d11b
https://netbasal.com/understanding-viewchildren-contentchildren-and-querylist-in-angular-896b0c689f6e
To Stephen Paul for the initial Angular 2 Modal version.
MIT © Gerard Rovira Sánchez
FAQs
Angular2+ Modal / Dialog (with inner component support).
The npm package angular-custom-modal receives a total of 215 weekly downloads. As such, angular-custom-modal popularity was classified as not popular.
We found that angular-custom-modal demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.