我在加载数据中使用离子2 HTTP获取了一些问题,但是它加载并显示成功,但是添加了一些数据后仍然显示相同。我尝试使用观察者,但它没有起作用,也许我不知道如何使用它...当我手动清除浏览器的缓存时,它可以正常工作,希望很快能收到您的声音。
import { Component } from '@angular/core';
import { NavController,NavParams,AlertController,LoadingController,ToastController } from 'ionic-angular'; import {Http} from '@angular/http'; import 'rxjs/add/operator/map'; import { Storage } from '@ionic/storage'; import { BarcodeScanner } from '@ionic-native/barcode-scanner'; import {Observable} from 'rxjs/observable';
@Component({ selector: 'page-home', templateUrl: 'home.html' }) export class HomePage { username; mypass; transactions:any; constructor(public storage:Storage,public navCtrl: NavController,public http:Http,public navParams: NavParams) { }
ionViewDidEnter() {
this.storage.ready().then(() =>
{
this.storage.get('credentials').then((val) =>
{
this.today(val['username'],val['mypass']);
this.username=val['username'];
this.mypass=val['mypass'];
});
}); }
today(user,pass) {
//I WILL QUERY PROCESSED ONE
this.http.get(myDataJSONApiUrl).map(res=>res.json()).subscribe( (data)=> {
this.transactions=data;
console.log(data); }, (err)=> {
console.log(err); });
}
}
仅通过将随机数附加到URL中,我就解决了问题。
随机号码每次都在URL上附加新的可varr-并使其变新,因此看起来像是在URL上入侵技巧,
var random = math.floor(math.random(( * 10000(; 返回this.http.get(" path/to/to/url& random =" random(.map(res => res.json(((;