11import { Component , OnInit , OnChanges , Input , Output , EventEmitter , SimpleChanges ,
2- DoCheck , AfterContentInit , AfterContentChecked } from '@angular/core' ;
2+ DoCheck , AfterContentInit , AfterContentChecked , AfterViewInit } from '@angular/core' ;
33
44@Component ( {
55 selector : 'app-product-details' ,
66 templateUrl : './product-details.component.html' ,
77 styleUrls : [ './product-details.component.css' ]
88} )
9- export class ProductDetailsComponent implements OnInit , OnChanges , DoCheck , AfterContentInit , AfterContentChecked {
9+ export class ProductDetailsComponent implements OnInit , OnChanges , DoCheck , AfterContentInit ,
10+ AfterContentChecked , AfterViewInit {
1011
1112 constructor ( ) { }
1213 @Input ( ) SalesRating :number = 3.5 ;
@@ -26,10 +27,14 @@ export class ProductDetailsComponent implements OnInit, OnChanges, DoCheck,After
2627 console . log ( "4 .after content init from child" ) ;
2728 }
2829
29- ngAfterContentChecked ( ) : void {
30+ ngAfterContentChecked ( ) : void {
3031 console . log ( "5. ngAfterContentChecked from child." ) ;
3132 }
3233
34+ ngAfterViewInit ( ) : void {
35+ console . log ( "6. ngAfterViewInit from child." ) ;
36+ }
37+
3338 onClick ( ) :void {
3439 this . GetLocalSales . emit ( `The local sales report for this product is ${ this . _salesRating } ` ) ;
3540 }
@@ -51,7 +56,6 @@ export class ProductDetailsComponent implements OnInit, OnChanges, DoCheck,After
5156 const prev = JSON . stringify ( chng . previousValue ) ;
5257 //console.log(`${propName}: currentValue = ${cur}, previousValue = ${prev}`);
5358 }
54-
5559 console . log ( "1. ngOnChanges called from child." ) ;
5660 }
5761}
0 commit comments