Skip to content

Commit 6b35d7c

Browse files
author
Your Name
committed
Angular Core Deep Dive
1 parent 7cb1ec3 commit 6b35d7c

File tree

1 file changed

+39
-11
lines changed

1 file changed

+39
-11
lines changed

src/app/course-card/course-card.component.ts

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import {
2+
AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit,
23
Attribute,
34
ChangeDetectionStrategy,
45
ChangeDetectorRef,
5-
Component,
6+
Component, DoCheck,
67
EventEmitter,
78
Input, OnChanges,
89
OnDestroy,
@@ -16,10 +17,12 @@ import {CoursesService} from '../services/courses.service';
1617
@Component({
1718
selector: 'course-card',
1819
templateUrl: './course-card.component.html',
19-
styleUrls: ['./course-card.component.css'],
20-
changeDetection: ChangeDetectionStrategy.OnPush
20+
styleUrls: ['./course-card.component.css']
2121
})
22-
export class CourseCardComponent implements OnInit, OnDestroy, OnChanges {
22+
export class CourseCardComponent implements
23+
OnInit, OnDestroy, OnChanges,
24+
AfterContentChecked, AfterViewChecked,
25+
AfterContentInit, AfterViewInit, DoCheck {
2326

2427
@Input()
2528
course: Course;
@@ -31,6 +34,8 @@ export class CourseCardComponent implements OnInit, OnDestroy, OnChanges {
3134
courseEmitter = new EventEmitter<Course>();
3235

3336

37+
38+
3439
constructor(private coursesService: CoursesService,
3540
@Attribute('type') private type: string) {
3641

@@ -41,36 +46,59 @@ export class CourseCardComponent implements OnInit, OnDestroy, OnChanges {
4146

4247
ngOnChanges(changes) {
4348

44-
console.log("ngOnChanges", changes);
49+
console.log('ngOnChanges', changes);
4550
}
4651

4752
ngOnInit() {
4853

49-
console.log("ngOnInit", this.course);
54+
console.log('ngOnInit');
55+
56+
57+
}
58+
59+
ngDoCheck() {
60+
console.log("ngDoCheck");
61+
}
5062

63+
ngAfterContentInit() {
64+
console.log("ngAfterContentInit");
65+
}
66+
67+
ngAfterViewInit() {
68+
console.log("ngAfterViewInit");
69+
}
70+
71+
72+
ngAfterContentChecked() {
73+
74+
console.log('ngAfterContentChecked');
75+
76+
}
77+
78+
ngAfterViewChecked() {
79+
80+
console.log('ngAfterViewChecked');
5181

5282
}
5383

5484
ngOnDestroy() {
5585

56-
console.log("ngOnDestroy");
86+
console.log('ngOnDestroy');
5787

5888
}
5989

60-
onTitleChanged(newTitle:string) {
90+
onTitleChanged(newTitle: string) {
6191

6292
this.course.description = newTitle;
6393

6494
}
6595

6696

67-
onSaveClicked(description:string) {
97+
onSaveClicked(description: string) {
6898

6999
this.courseEmitter.emit({...this.course, description});
70100

71101
}
72102

73103

74-
75-
76104
}

0 commit comments

Comments
 (0)