我有一个组件,我想在其中加载从后端接收的对象.
ngOnInit() {
this.source.load(this.myService.findAll());
}
在myService中,我使用Axios从后端获取数据.我可以看到数据到达了前台
public findAll(): any {
axios.get('http://localhost:8080/api/getAll')
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log(error);
})
}
如何从组件调用服务,以便接收对象数组?