66 * found in the LICENSE file at https://angular.dev/license
77 */
88/* tslint:disable:no-console */
9- import { Component , Directive , EventEmitter , NgModule } from '@angular/core' ;
9+ import { Component , Directive , output } from '@angular/core' ;
1010
1111// #docregion component-input
1212@Component ( {
1313 selector : 'app-bank-account' ,
1414 inputs : [ 'bankName' , 'id: account-id' ] ,
1515 template : ` Bank Name: {{ bankName }} Account Id: {{ id }} ` ,
16- standalone : false ,
1716} )
1817export class BankAccountComponent {
1918 bankName : string | null = null ;
@@ -25,35 +24,32 @@ export class BankAccountComponent {
2524
2625@Component ( {
2726 selector : 'app-my-input' ,
28- template : ` <app-bank-account bankName="RBC" account-id="4747"> </app-bank-account > ` ,
29- standalone : false ,
27+ template : ` <app-bank-account bankName="RBC" account-id="4747" / > ` ,
28+ imports : [ BankAccountComponent ] ,
3029} )
3130export class MyInputComponent { }
3231// #enddocregion component-input
3332
3433// #docregion component-output-interval
3534@Directive ( {
3635 selector : 'app-interval-dir' ,
37- outputs : [ 'everySecond' , 'fiveSecs: everyFiveSeconds' ] ,
38- standalone : false ,
3936} )
4037export class IntervalDirComponent {
41- everySecond = new EventEmitter < string > ( ) ;
42- fiveSecs = new EventEmitter < string > ( ) ;
38+ everySecond = output < string > ( ) ;
39+ everyFiveSeconds = output < string > ( ) ;
4340
4441 constructor ( ) {
4542 setInterval ( ( ) => this . everySecond . emit ( 'event' ) , 1000 ) ;
46- setInterval ( ( ) => this . fiveSecs . emit ( 'event' ) , 5000 ) ;
43+ setInterval ( ( ) => this . everyFiveSeconds . emit ( 'event' ) , 5000 ) ;
4744 }
4845}
4946
5047@Component ( {
5148 selector : 'app-my-output' ,
5249 template : `
53- <app-interval-dir (everySecond)="onEverySecond()" (everyFiveSeconds)="onEveryFiveSeconds()">
54- </app-interval-dir>
50+ <app-interval-dir (everySecond)="onEverySecond()" (everyFiveSeconds)="onEveryFiveSeconds()" />
5551 ` ,
56- standalone : false ,
52+ imports : [ IntervalDirComponent ] ,
5753} )
5854export class MyOutputComponent {
5955 onEverySecond ( ) {
@@ -64,8 +60,3 @@ export class MyOutputComponent {
6460 }
6561}
6662// #enddocregion component-output-interval
67-
68- @NgModule ( {
69- declarations : [ BankAccountComponent , MyInputComponent , IntervalDirComponent , MyOutputComponent ] ,
70- } )
71- export class AppModule { }
0 commit comments