mirror of
https://github.com/LukeHagar/unicorn-utterances.git
synced 2025-12-07 12:57:45 +00:00
docs: finalize adding code samples and embeds
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Red Directive</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 injectAndMakeRed = () => {
|
||||
const el = inject(ElementRef);
|
||||
el.nativeElement.style.backgroundColor = "red";
|
||||
el.nativeElement.style.color = "white";
|
||||
};
|
||||
|
||||
@Directive({
|
||||
selector: "[red]",
|
||||
standalone: true,
|
||||
})
|
||||
class RedDirective {
|
||||
_el = injectAndMakeRed();
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: "app-root",
|
||||
standalone: true,
|
||||
imports: [RedDirective],
|
||||
template: ` <p red>This is red</p> `,
|
||||
})
|
||||
class AppComponent {}
|
||||
|
||||
bootstrapApplication(AppComponent);
|
||||
Reference in New Issue
Block a user