import { Component, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core'; import { ModelService } from '../shared/model/model.service'; @Component({ changeDetection: ChangeDetectionStrategy.Default, encapsulation: ViewEncapsulation.Emulated, selector: 'todo', styles: [` `], template: `
Todo component
` }) export class TodoComponent { newTodo = ''; todos = []; constructor(public model: ModelService) { // we need the data synchronously for the client to set the server response // we create another method so we have more control for testing this.universalInit(); } addTodo(newTodo) { this.todos.push(newTodo); this.newTodo = ''; } universalInit() { } }