diff --git a/src/app/app.component.html b/src/app/app.component.html index c99d8485..627e487b 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -7,21 +7,13 @@
+ + + + + + + -
- -
- Angular Core Deep Dive -
- Angular Logo - -
- A detailed walk-through of the most important part of Angular - the Core and Common modules. -
- -
- - diff --git a/src/app/app.component.ts b/src/app/app.component.ts index f0fd8bb8..2c075d50 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,6 @@ import { Component } from '@angular/core'; import {COURSES} from '../db-data'; +import { Course } from './model/course'; @Component({ selector: 'app-root', @@ -7,7 +8,24 @@ import {COURSES} from '../db-data'; styleUrls: ['./app.component.css'] }) export class AppComponent { - +// this is how we make available the course objects so that we can display different course cards +// now these are available in the AppComponent template +// { this is how the elements of array COURSES look like +// id: 1, +// description: "Angular Core Deep Dive", +// iconUrl: 'https://s3-us-west-1.amazonaws.com/angular-university/course-images/angular-core-in-depth-small.png', +// longDescription: "A detailed walk-through of the most important part of Angular - the Core and Common modules", +// category: 'INTERMEDIATE', +// lessonsCount: 10 +// } +// these are defined in db-data.ts +// bexause we are displaying these in the template of the app component + coreCourse = COURSES[0]; + rjsCourse = COURSES[1]; + ngrxCourse = COURSES[2]; + onCourseSelected(course: Course) { + console.log("App component - click event bubbled...", course) + } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index de5e54de..d9dcb35d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -3,10 +3,12 @@ import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { CourseCardComponent } from './course-card/course-card.component'; @NgModule({ declarations: [ - AppComponent + AppComponent, + CourseCardComponent ], imports: [ BrowserModule, diff --git a/src/app/course-card/course-card.component.css b/src/app/course-card/course-card.component.css new file mode 100644 index 00000000..f5a3215f --- /dev/null +++ b/src/app/course-card/course-card.component.css @@ -0,0 +1 @@ +/* we will */ diff --git a/src/app/course-card/course-card.component.html b/src/app/course-card/course-card.component.html new file mode 100644 index 00000000..02daca75 --- /dev/null +++ b/src/app/course-card/course-card.component.html @@ -0,0 +1,15 @@ + +
+ +
+ + {{ course.description }} +
+ Angular Logo +
+ {{ course.longDescription }} +
+ + +
diff --git a/src/app/course-card/course-card.component.spec.ts b/src/app/course-card/course-card.component.spec.ts new file mode 100644 index 00000000..7967a9ac --- /dev/null +++ b/src/app/course-card/course-card.component.spec.ts @@ -0,0 +1,26 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CourseCardComponent } from './course-card.component'; + +describe('CourseCardComponent', () => { + let component: CourseCardComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ CourseCardComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CourseCardComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); +// another comment diff --git a/src/app/course-card/course-card.component.ts b/src/app/course-card/course-card.component.ts new file mode 100644 index 00000000..493a30a0 --- /dev/null +++ b/src/app/course-card/course-card.component.ts @@ -0,0 +1,30 @@ +import { Component, EventEmitter, OnInit , Input, Output} from '@angular/core'; +import { COURSES } from '../../db-data'; +import { Course } from '../model/course'; + +@Component({ + selector: 'course-card', // defines html tag + templateUrl: './course-card.component.html', + styleUrls: ['./course-card.component.css'] +}) +export class CourseCardComponent implements OnInit { +//need to import Input or it will not compile!! + @Input() + course: Course; // from the model folder + + // emit custom event (note the type Course passed) + @Output() + courseSelected = new EventEmitter(); + + constructor() { } + + ngOnInit(): void { + } + + onCourseViewed() { + console.log("card component button clicked"); + this.courseSelected.emit(this.course); + } + +} +// comment