mirror of
https://github.com/LukeHagar/unicorn-utterances.git
synced 2025-12-06 04:21:55 +00:00
29 lines
563 B
TypeScript
29 lines
563 B
TypeScript
import "zone.js";
|
|
import { bootstrapApplication } from "@angular/platform-browser";
|
|
|
|
import { Component, Directive } from "@angular/core";
|
|
|
|
@Directive({
|
|
selector: '[red]',
|
|
standalone: true,
|
|
host: {
|
|
'[style]': `selected ? 'background-color: red; color: white;' : ''`,
|
|
'(click)': 'selected = !selected',
|
|
},
|
|
})
|
|
class RedDirective {
|
|
selected = false;
|
|
}
|
|
|
|
@Component({
|
|
selector: 'app-root',
|
|
standalone: true,
|
|
imports: [RedDirective],
|
|
template: `
|
|
<p red>This is red when I am selected</p>
|
|
`,
|
|
})
|
|
class AppComponent {}
|
|
|
|
bootstrapApplication(AppComponent);
|