import {Component} from '@angular/core'; import {initialEntries} from './initialEntries'; import {BlogEntry} from './blog-entry'; @Component({ moduleId: module.id, selector: 'app-root', templateUrl: 'app.component.html' }) export class AppComponent { entries: BlogEntry[] = []; id = 2; constructor() { this.entries = []; this.entries = initialEntries } createBlogEntry(title:string, image:string, text:string) { this.id++; console.log(this.id, title, image, text); let entry = new BlogEntry(); entry.id = this.id; entry.title = title; entry.image = image; entry.text = text; this.entries.push(entry); } deleteBlogEntry(id:number) { let entryIndex = this.entries.findIndex(entry => entry.id === id); if (entryIndex > -1) { this.entries.splice(entryIndex, 1); } } }