我正在尋找這個問題的解決方案超過3天,並找不到任何東西..AngularJS - POST請求重裝
我有ionic3應用程序和工作寬度Http POST請求。我將請求發送到我的PHP服務器和歌廳數據..
我的數據api.ts(供應商)
public getNotifications(token){
return this.http.post(this.sharedVars.getApi(),"action=messages/notification&token="+token, this.options
).map(res => res.json());
}
profilePage.ts
notifications() {
this.api.getNotifications(this.user.token).subscribe(
data => {
if(data.err == 0){
this.notifications = data.data;
}
},
err => {
console.log(err);
}
);
}
這是工作職能和我當點擊此功能時得到正確的輸出(1)。但在我的服務器上的x動作通知計數將更改爲2,3,4等。我想加載此功能不點擊,但在頁面加載。所以如果this.notifications
有新的價值我想改變生活價值(如作爲火力點)
例2:
我有我的數據api.ts發送消息的行動(供應商)
public sendMessage(token, to, message, attachment){
return this.http.post(this.sharedVars.getApi(),"action=messages/send&token="+token+"&to="+to+"&message="+message+"&attachment="+attachment, this.options
).map(res => res.json());
}
和也有功能得到這個消息。
public getActivity(token){
return this.http.post(this.sharedVars.getApi(),"action=messages/getActivity&token="+token, this.options
).map(res => res.json());
}
所以,如果我提出POST請求sendMessage
然後我想聽聽現場getActivity
行動,並在我的網頁加載新的消息,但不會重新加載..喜歡的火力..
我希望這個問題是清楚的。因爲我不是說英語的人,而且努力尋找解決方案。坦克