import { Component ,OnInit} from '@angular/core'; import { Http } from '@angular/http'; import { Goods,Member } from './../../app.class'; @Component({ moduleId: module.id, selector: 'goods-list', templateUrl: './goods.component.html' }) export class GoodsComponent implements OnInit{ goodslist:any; item:any={name:"",images:"",price:"",nick:"",mobile:"",description:""}; constructor(public http:Http){this.http=http;}; ngOnInit(){ let goods=new Goods(this.http); goods.list(res=>{this.goodslist=res;}); } deleteGoods(id){ let goods=new Goods(this.http); goods.delete(id,res=>{ goods.list(res=>{this.goodslist=res;}); alert(res.message); }); } showGoods(goods:any){ this.item=goods; } }