import { Component, OnInit, Input } from '@angular/core'; import { BlogService } from 'src/app/shared/services/blog.service'; import { BlogEntry } from 'tournee.businesslogic'; @Component({ selector: 'app-blog-roll', templateUrl: './blog-roll.component.html', styleUrls: ['./blog-roll.component.css'], providers: [ BlogService ] }) export class BlogRollComponent implements OnInit { BlogEntries: Array = []; @Input() Limit: number = 3; constructor(private _blogs: BlogService) { } ngOnInit() { this._blogs.get_roll(this.Limit) .then((result) => { this.BlogEntries = result.result.map((b) => { return new BlogEntry(b); }); }) .catch((err) => { console.log(err); }); } ColumnClass() { if (this.BlogEntries.length == 1) { return 'col-sm-6 offset-sm-3'; } else if (this.BlogEntries.length == 2) { return 'col-sm-6 col-md-4 offset-md-1'; } else { return 'col-sm-4'; } } }