首先,我是Typescript和Angular 2的新手,这似乎是一个明显的答案,但我似乎无法让它工作.我有以下型号
export interface IBrand {
brandID: number;
name: string;
image: string;
}
Run Code Online (Sandbox Code Playgroud)
然后我有组件类
import { Component, OnInit } from '@angular/core';
import { Router, RouteParams } from '@angular/router-deprecated'
import { bootstrap } from '@angular/platform-browser-dynamic';
import { IBrand } from './brand';
import { BrandService } from './brand.service';
@Component({
selector: 'data-bind',
templateUrl: 'app/dashboardApp/brands/brand-list.component.html',
styleUrls: ['app/dashboardApp/brands/brand-list.component.css']
})
export class BrandListComponent implements OnInit {
brands: IBrand[];
errorMessage: string;
newBrand: IBrand;
pageTitle: string = 'Brands';
constructor(private _brandService: BrandService,
private _router: Router) {
}
ngOnInit(): void …Run Code Online (Sandbox Code Playgroud) angular ×1