简要说明:home.ts
使用OnInit()
函数中的以下代码从服务中获取数据:
this._http.get(this._url+this.SNO+"&"+this.randomno,{headers:headers})
.subscribe(data => {this.list=data.json();
现在这个页面有一个添加新记录的字段。我正在做的是,一旦用户添加记录,我基本上使用以下代码重新加载页面:
this.navCtrl.setRoot(CommunicationPage
我想刷新数据而不重新加载页面,我该怎么做?
请指教。
在我的例子中,我将所有参数保存到数据变量中
data: any = {};
ngOnInit(): void {
this.route.queryParams.subscribe((params: any) => {
this.data = {...params};
this.countriesService.getCountries(this.data).subscribe((res: any) => {
this.countries = res.data.countries
})
});
}
当我想“刷新”我的数据列表时,我正在这样做
searchCountries() {
this.data.random = Math.random();
this.router.navigate([], {queryParams: this.data });
}
那是你在找什么?