Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Component } from '@angular/core';
  2. import { Todo } from './todo';
  3. import { TodoService } from './todo.service';
  4.  
  5. @Component({
  6.   selector: 'my-app',
  7.   template: `<h1>My todo list</h1>
  8.   <ul>
  9.       <li *ngFor="let todo of todos">
  10.         {{todo.todo}} - {{todo.isDone}}
  11.       </li>
  12.     </ul>`,
  13.   providers: [ TodoService ]
  14. })
  15. export class AppComponent  {
  16.   todos: Todo[];
  17.   constructor(private todoService: TodoService) { }
  18.   getTodos(): void {
  19.     this.todoService.getTodos().then(todos => this.todos = todos);
  20.   }
  21.   ngOnInit(): void {
  22.     this.getTodos();
  23.   }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement