[英]display data in html with angular4
i'm using angular 4 and springboot to build an app but i have a problem i want to display a count object in html and i don't know how this is my repository 我正在使用angular 4和springboot来构建一个应用程序,但我有一个问题,我想在html中显示一个计数对象,我不知道这是如何我的存储库
@Query("select count (c) from Contact c")
int getCountOfContact();
my service.ts 我的服务
getContactCount(){
return this.http.get("http://localhost:9090/contact/count")
.map(resp=>resp.json());
}
my component.ts 我的组件
getCountConact(){
this.dashboardservice.getContactCount().subscribe((data)=>{
console.log(data);
},(error)=>{
console.log(error);
})
}
how can i have the result in my component.html 我怎么能在我的component.html中得到结果
What is the actual problem? 实际问题是什么? Does your service returns the exptected result?
您的服务是否返回已检测到的结果? If so, you should save it to a variable and then you can bind it in the html.
如果是这样,你应该将它保存到变量,然后你可以在html中绑定它。 component.ts
component.ts
data: any;
getCountConact(){
this.dashboardservice.getContactCount().subscribe((data)=>{
this.data = data;
console.log(data);
},(error)=>{
console.log(error);
})
}
and html: 和HTML:
<div>
{{ result }}
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.