component代码
import { Component,OnInit } from '@angular/core';
import { InterceptorService } from '../../../share/interceptor.service';
import { Router,ActivatedRoute } from '@angular/router';
import { HomeInfoEntity } from '../../../models/home-info-entity';
@Component({
selector: 'app-familyinfo',templateUrl: './familyinfo.component.html',styleUrls: ['./familyinfo.component.css']
})
export class FamilyinfoComponent implements OnInit {
id: string;
familylist:HomeInfoEntity[]=[];
private tableUrl:string = "graduate-web/homeInfo/findeByUserId/";
//data = new Array();
constructor(
private router:Router,private http:InterceptorService,private route: ActivatedRoute){}
getData(isQuery?: boolean) {
let id ='0044fbbe28c254673bc37a';
let url = this.tableUrl + id;
this.http.get(url).subscribe(
res => {
console.log(res.json().message + '!!!!!!');
if (res.json().code == "0000") {
this.familylist = res.json().data;
}
}
)
}
ngOnInit() {
let id ='0044fbbe28c254673bc37a';
let homeInfoEntity: HomeInfoEntity = new HomeInfoEntity;
homeInfoEntity.userId = this.id;
this.familylist.push(homeInfoEntity);
this.getData(true);//测试查询
}
delete(){
var btnArray = ['确认','取消'];
var elem = this;
//var li = elem.parentNode.parentNode;
mui.confirm('确认删除该条记录?','删除',btnArray,function(e){
if(e.index==0){
}else{
}
})
}
detailsmode(){/*点击添加按钮跳转到详细信息*/
this.router.navigateByUrl('/workspace/family/familydetails');
}
modify(i:number){
let familyinfo: HomeInfoEntity = this.familylist[i];
let familyInfoId: string = familyinfo.id;
this.router.navigateByUrl('workspace/family/familydetails'+"/"+familyInfoId);
}
}
原文链接:https://www.f2er.com/angularjs/144474.html