Skip to content

Commit ec34ae6

Browse files
author
Your Name
committed
typescript course ongoing
1 parent 48757b2 commit ec34ae6

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

client/src/app/app.component.html

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

66
<div class="main-container">
77
<div class="list">
8-
<course-detail></course-detail>
8+
<course-detail [courseDetail]="course$ | async"></course-detail>
99
</div>
1010
</div>
1111

client/src/app/app.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {Component, OnInit} from '@angular/core';
22
import {CoursesService} from "./services/courses.service";
3+
import {CourseDetail} from "../../../shared/model/course-detail";
4+
import {Observable} from "rxjs";
35

46
@Component({
57
selector: 'app-root',
@@ -8,13 +10,14 @@ import {CoursesService} from "./services/courses.service";
810
})
911
export class AppComponent implements OnInit {
1012

13+
course$: Observable<CourseDetail>;
14+
1115
constructor(private coursesService:CoursesService) {
1216

1317
}
1418

1519
ngOnInit() {
16-
this.coursesService.loadCourseDetail(1)
17-
.subscribe(console.log);
20+
this.course$ = this.coursesService.loadCourseDetail(1);
1821
}
1922

2023
}
Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1-
<p>
2-
course-detail works!
3-
</p>
1+
<h2>{{courseDetail?.description}}</h2>
2+
3+
4+
<div class="lessons-list-container v-h-center-block-parent">
5+
6+
<table class="table lessons-list card card-strong">
7+
<tbody>
8+
<tr *ngFor="let lesson of courseDetail?.lessons">
9+
<td class="lesson-title">{{lesson.description}}</td>
10+
<td class="duration">
11+
<i class="md-icon duration-icon">access_time</i>
12+
<span>{{lesson.duration}}</span>
13+
</td>
14+
</tr>
15+
</tbody>
16+
</table>
17+
18+
</div>

client/src/app/course-detail/course-detail.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, OnInit ,Input} from '@angular/core';
2+
import {CourseDetail} from "../../../../shared/model/course-detail";
23

34
@Component({
45
selector: 'course-detail',
@@ -7,6 +8,9 @@ import { Component, OnInit } from '@angular/core';
78
})
89
export class CourseDetailComponent implements OnInit {
910

11+
@Input()
12+
courseDetail:CourseDetail;
13+
1014
constructor() {
1115

1216

client/src/app/services/courses.service.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ export class CoursesService {
1313

1414
}
1515

16-
17-
1816
loadCourseDetail(courseId: number) :Observable<CourseDetail> {
1917

2018
return this.http.get(`/api/courses/${courseId}`)

0 commit comments

Comments
 (0)