mirror of
https://github.com/LukeHagar/unicorn-utterances.git
synced 2025-12-11 04:22:07 +00:00
docs: add dynamic host first three samples
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Alert On Destroy</title>
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,30 @@
|
||||
import "zone.js";
|
||||
import { bootstrapApplication } from "@angular/platform-browser";
|
||||
|
||||
import { Component, Directive, OnDestroy } from "@angular/core";
|
||||
import { NgIf } from "@angular/common";
|
||||
|
||||
@Directive({
|
||||
selector: '[alertOnDestroy]',
|
||||
standalone: true,
|
||||
})
|
||||
class AlertOnDestroyDirective implements OnDestroy {
|
||||
ngOnDestroy() {
|
||||
alert('Element was unrendered!');
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
standalone: true,
|
||||
imports: [AlertOnDestroyDirective, NgIf],
|
||||
template: `
|
||||
<p *ngIf="render" alertOnDestroy>Unmount me to see an alert!</p>
|
||||
<button (click)="render = !render">Toggle</button>
|
||||
`,
|
||||
})
|
||||
class AppComponent {
|
||||
render = true;
|
||||
}
|
||||
|
||||
bootstrapApplication(AppComponent);
|
||||
Reference in New Issue
Block a user