-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add example of using
input.required
- Loading branch information
Showing
2 changed files
with
9 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 6 additions & 5 deletions
11
examples/example-app-v17/src/app/dashboard/dashboard-hero.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
import { UpperCasePipe } from '@angular/common'; | ||
import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { Component, input, output } from '@angular/core'; | ||
|
||
import { Hero } from '../model/hero'; | ||
|
||
@Component({ | ||
selector: 'dashboard-hero', | ||
template: ` <div (click)="click()" class="hero"> | ||
{{ hero.name | uppercase }} | ||
{{ hero().name | uppercase }} | ||
</div>`, | ||
styleUrls: ['./dashboard-hero.component.css'], | ||
standalone: true, | ||
imports: [UpperCasePipe], | ||
}) | ||
export class DashboardHeroComponent { | ||
@Input() hero!: Hero; | ||
@Output() selected = new EventEmitter<Hero>(); | ||
hero = input.required<Hero>(); | ||
readonly selected = output<Hero>(); | ||
|
||
click() { | ||
this.selected.emit(this.hero); | ||
this.selected.emit(this.hero()); | ||
} | ||
} |