mirror of
https://github.com/LukeHagar/unicorn-utterances.git
synced 2025-12-07 12:57:45 +00:00
docs: add two more examples
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Listen for Events</title>
|
||||
</head>
|
||||
<body>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,28 @@
|
||||
import "zone.js";
|
||||
import { bootstrapApplication } from "@angular/platform-browser";
|
||||
|
||||
import { Component, Directive, ElementRef, inject } from "@angular/core";
|
||||
|
||||
const injectAndGetEl = () => {
|
||||
const el = inject(ElementRef);
|
||||
console.log(el.nativeElement);
|
||||
return el;
|
||||
};
|
||||
|
||||
@Directive({
|
||||
selector: "[logEl]",
|
||||
standalone: true,
|
||||
})
|
||||
class LogElDirective {
|
||||
_el = injectAndGetEl();
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: "app-root",
|
||||
standalone: true,
|
||||
imports: [LogElDirective],
|
||||
template: ` <p logEl>This paragraph tag will be logged!</p> `,
|
||||
})
|
||||
class AppComponent {}
|
||||
|
||||
bootstrapApplication(AppComponent);
|
||||
Reference in New Issue
Block a user