Skip to content

Commit 7508ecb

Browse files
author
Your Name
committed
Angular Core Deep Dive
1 parent 2bc5992 commit 7508ecb

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<div class="courses" *ngIf="courses$ | async as courses">
1111

12-
<course-card *ngFor="let course of courses"
12+
<course-card highlighted *ngFor="let course of courses"
1313
(courseChanged)="save($event)"
1414
[course]="course">
1515

src/app/app.component.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
import {AfterViewInit, Component, ElementRef, Inject, InjectionToken, OnInit, QueryList, ViewChild, ViewChildren} from '@angular/core';
1+
import {
2+
AfterViewInit,
3+
Component,
4+
ElementRef,
5+
Inject,
6+
InjectionToken,
7+
OnInit,
8+
Optional,
9+
QueryList,
10+
ViewChild,
11+
ViewChildren
12+
} from '@angular/core';
213
import {COURSES} from '../db-data';
314
import {Course} from './model/course';
415
import {CourseCardComponent} from './course-card/course-card.component';
@@ -12,7 +23,10 @@ import {APP_CONFIG, AppConfig, CONFIG_TOKEN} from './config';
1223
@Component({
1324
selector: 'app-root',
1425
templateUrl: './app.component.html',
15-
styleUrls: ['./app.component.css']
26+
styleUrls: ['./app.component.css'],
27+
providers: [
28+
CoursesService
29+
]
1630
})
1731
export class AppComponent implements OnInit {
1832

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import {
66
ElementRef,
77
EventEmitter, Inject,
88
Input,
9-
OnInit,
9+
OnInit, Optional,
1010
Output,
11-
QueryList,
11+
QueryList, Self, SkipSelf,
1212
ViewEncapsulation
1313
} from '@angular/core';
1414
import {Course} from '../model/course';

src/app/directives/highlighted.directive.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {Directive, EventEmitter, HostBinding, HostListener, Input, Output} from '@angular/core';
1+
import {Directive, EventEmitter, Host, HostBinding, HostListener, Input, Output} from '@angular/core';
2+
import {CoursesService} from '../services/courses.service';
23

34
@Directive({
45
selector: '[highlighted]',
@@ -12,9 +13,9 @@ export class HighlightedDirective {
1213
@Output()
1314
toggleHighlight = new EventEmitter();
1415

15-
constructor() {
16+
constructor(private coursesService: CoursesService) {
1617

17-
console.log('Directive created..');
18+
console.log('coursesService highlighted ' + coursesService.id);
1819

1920
}
2021

0 commit comments

Comments
 (0)