Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aae8f2a

Browse files
ngAfterViewInit added
1 parent ec72a8d commit aae8f2a

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

‎src/app/product-details/product-details.component.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { 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
}

‎src/app/products/products.component.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
import { Component, OnInit,SimpleChanges, OnChanges, DoCheck,
2-
AfterContentInit, AfterContentChecked } from '@angular/core';
2+
AfterContentInit, AfterContentChecked,AfterViewInit } from '@angular/core';
33

44
@Component({
55
selector: 'app-products',
66
templateUrl: './products.component.html',
77
styleUrls: ['./products.component.css']
88
})
99

10-
export class ProductsComponent implements OnInit, OnChanges, DoCheck,AfterContentInit, AfterContentChecked {
10+
export class ProductsComponent implements OnInit, OnChanges, DoCheck,AfterContentInit,
11+
AfterContentChecked, AfterViewInit {
1112

1213
constructor() { }
1314

14-
ngOnInit(): void {
15-
console.log("2. ngOnInit called from parent.");
16-
}
17-
1815
ngOnChanges(changes: SimpleChanges) : void{
1916
for (const propName in changes) {
2017
const chng = changes[propName];
@@ -24,6 +21,10 @@ export class ProductsComponent implements OnInit, OnChanges, DoCheck,AfterConten
2421
}
2522
console.log("1. ngOnChanges called from parent.");
2623
}
24+
25+
ngOnInit(): void {
26+
console.log("2. ngOnInit called from parent.");
27+
}
2728

2829
ngDoCheck(): void {
2930
console.log("3. doCheck is called from parent.") ;
@@ -37,6 +38,10 @@ export class ProductsComponent implements OnInit, OnChanges, DoCheck,AfterConten
3738
console.log("5. ngAfterContentChecked from parent.");
3839
}
3940

41+
ngAfterViewInit(): void{
42+
console.log("6. ngAfterViewInit from parent.");
43+
}
44+
4045
messageFromNestedComponent = '';
4146
onGetLocalSalesReport(message:string) : void {
4247
this.messageFromNestedComponent = 'Product Details Report: ' + message;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /