-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added data service, used but list component
- Loading branch information
tobias.wright
committed
Apr 26, 2023
1 parent
6371b70
commit c008e33
Showing
6 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
<p>{{cause}}</p> | ||
<p>{{htmlcolor}}</p> | ||
</div> | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { DataService } from './../data.service' | ||
|
||
@Component({ | ||
selector: 'app-color-list', | ||
templateUrl: './color-list.component.html', | ||
styleUrls: ['./color-list.component.css'] | ||
}) | ||
export class ColorListComponent { | ||
list: {"cause":string, "htmlcolor":string}[] =[{"cause":"Breast Cancer","htmlcolor":"pink"},{"cause":"Birth Parents","htmlcolor":"pink"},{"cause":"Nursing Mothers","htmlcolor":"pink"}] | ||
constructor(private data: DataService) { } | ||
|
||
list = this.data.getList() | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { DataService } from './data.service'; | ||
|
||
describe('DataService', () => { | ||
let service: DataService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(DataService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Injectable } from '@angular/core'; | ||
import data from '../assets/data.json' | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class DataService { | ||
|
||
constructor() { } | ||
getList(){ | ||
return data | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters