import 'rxjs/add/operator/switchMap'; import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { AngularmService } from '../../angularm.service'; import { EntityTypeComponent } from '../../meta/entitytype.component'; import { FlashMessageService } from '../simple/flash.message.service'; import { Entity } from '../../entitytype'; import { TitleCase } from '../../pipes/titlecase.pipe'; @Component({ selector: 'div [mgListingTable]', template: `

Listing {{ entityType.plural | titleCase }}

{{propertyType.name | titleCase}}
New {{entityType.singular | titleCase}} Back
` }) export class ListingTableComponent extends EntityTypeComponent implements OnInit { constructor( private router: Router, private flash: FlashMessageService, angularm: AngularmService ) { super(angularm); } ngOnInit() { this.angularm.listAll(this.entityType.singular).then( entities => this.entities = entities ); } back() { this.flash.clearMessage(); this.router.navigate(['/']); return false; } create() { this.flash.clearMessage(); this.router.navigate([this.entityType.plural, 'new']); return false; } }