component.ts文件
从'@ angular / core'导入{Component,OnInit,Input};
从'../../../../shared/history.service'导入{HistoryService};
从“ @ angular / router”导入{Router};
从'@ angular / forms'导入{NgForm};
从'../../../../shared/history.model'中导入{历史记录};
@Component({
selector: 'app-ins-history',
templateUrl: './ins-history.component.html',
styleUrls: ['./ins-history.component.css'],
providers:[HistoryService]
})
export class InsHistoryComponent implements OnInit {
constructor(public UserProfileService: HistoryService, private router: Router) { }
ngOnInit() {
this.HistoryList();
}
HistoryList()
{ let title = this.UserProfileService.Title;
console.log(title);
this.UserProfileService.getHistoryList(title).subscribe((res)=> {
this.UserProfileService.history= res as History[];
alert('ok');
});
}
}[historyservice.ts][1]