File tree Expand file tree Collapse file tree 2 files changed +14
-23
lines changed
Expand file tree Collapse file tree 2 files changed +14
-23
lines changed Original file line number Diff line number Diff line change 1+ import { CourseService } from './course.service' ;
12import { Component , OnInit } from '@angular/core' ;
23import { Course } from './course' ;
34
@@ -9,29 +10,8 @@ import { Course } from './course';
910export class CourseListComponent implements OnInit {
1011
1112 courses : Course [ ] = [ ] ;
12-
13+ constructor ( private courseService : CourseService ) { }
1314 ngOnInit ( ) : void {
14- this . courses = [
15- {
16- id : 1 ,
17- name : "Angular" ,
18- imageUrl : "/assets/images/forms.png" ,
19- price : 99.99 ,
20- code : "XPS123" ,
21- duration : 120 ,
22- rating : 4.5 ,
23- releaseDate : "November, 2, 2019"
24- } ,
25- {
26- id : 2 ,
27- name : "Angular" ,
28- imageUrl : "/assets/images/http.png" ,
29- price : 99.99 ,
30- code : "XPS123" ,
31- duration : 120 ,
32- rating : 4.0 ,
33- releaseDate : "November, 4, 2019"
34- }
35- ]
15+ this . courses = this . courseService . retriveAll ( ) ;
3616 }
3717}
Original file line number Diff line number Diff line change 11import { Course } from './course' ;
2+ import { Injectable } from '@angular/core' ;
23
4+
5+ @Injectable ( {
6+ providedIn : "root"
7+ } )
38export class CourseService {
49
10+
11+
12+ retriveAll ( ) : Course [ ] {
13+ return COURSES ;
14+ }
15+
516}
617
718var COURSES : Course [ ] = [
You can’t perform that action at this time.
0 commit comments