Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f389a3
commit 9b13f6b
Showing
3 changed files
with
29 additions
and
15 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 |
---|---|---|
@@ -1,15 +1,25 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
import { TodoService } from './todo.service'; | ||
|
||
@Component({ | ||
selector: 'app-todo', | ||
templateUrl: './todo.component.html', | ||
styleUrls: ['./todo.component.scss'] | ||
styleUrls: ['./todo.component.scss'], | ||
providers: [TodoService] | ||
}) | ||
export class TodoComponent implements OnInit { | ||
private todos; | ||
|
||
constructor() { } | ||
constructor(private todoService: TodoService) { } | ||
|
||
ngOnInit() { | ||
getTodos(){ | ||
return this.todoService.get().then(todos => { | ||
this.todos = todos; | ||
}); | ||
} | ||
|
||
ngOnInit() { | ||
this.getTodos(); | ||
} | ||
} |
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,8 +1,19 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
let todos = [ | ||
{ title: 'Install Angular CLI', isDone: true }, | ||
{ title: 'Style app', isDone: true }, | ||
{ title: 'Finish service functionality', isDone: false }, | ||
{ title: 'Setup API', isDone: false }, | ||
]; | ||
|
||
@Injectable() | ||
export class TodoService { | ||
|
||
constructor() { } | ||
|
||
get(){ | ||
return new Promise(resolve => resolve(todos)); | ||
} | ||
|
||
} |