i have 2 components one of them work fine, and the other make the problem …it’s not update the values of parameters until change the page and return again …or turn off the mobile and turn on again …i don’t know what is the problem and i search about it in the internet but i don’t find any thing related …can you help me please
my class:
import { Component } from ‘@angular/core’;
import { NavController, NavParams } from ‘ionic-angular’;
import { Http,Headers,RequestOptions } from ‘@angular/http’;
import { Device } from ‘@ionic-native/device’;
/**
- Generated class for the NotificationDetailsPage page.
- See http://ionicframework.com/docs/components/#navigation for more info
- on Ionic pages and navigation.
*/
@Component({
selector: ‘page-notification-details’,
templateUrl: ‘notification-details.html’,
})
export class NotificationDetailsPage {
public notification:any;
public notification_type:string;
public my_love:string;
public loved:any;
device_id:any;
constructor(public navCtrl: NavController, public navParams: NavParams, public http: Http,private device: Device) {
this.notification=navParams.get(“notification_object”);
this.notification_type=navParams.get(“notification_type”);
this.my_love=this.notification.my_love;
this.loved=this.notification.loved;
if(!this.notification.my_watch){
this.product_watched();
this.notification.my_watch=“true”;
}
}
ionViewDidLoad() {
console.log(‘ionViewDidLoad NotificationDetailsPage’);
}
product_loved() {
var headers = new Headers();
headers.append("Accept", 'application/json');
headers.append('Content-Type', 'application/json' );
let options = new RequestOptions({ headers: headers });
this.device_id="'"+this.device.uuid+"'";
let postParams = {
id:this.notification.id,
uuid: this.device_id
}
// alert(JSON.stringify(postParams));
this.http.post("http://pro-apps.net/steps-me/api/product_loved", postParams, options)
.subscribe(data => {
this.notification.loved++;
this.notification.my_love="true";
//alert(this.notification.loved);
//alert(this.notification.my_love);
// alert(this.notification);
}, error => {
alert(error);// Error getting the data
});
}
product_watched() {
var headers = new Headers();
headers.append(“Accept”, ‘application/json’);
headers.append(‘Content-Type’, ‘application/json’ );
let options = new RequestOptions({ headers: headers });
this.device_id="’"+this.device.uuid+"’";
let postParams = {
id:this.notification.id,
uuid: this.device_id
}
console.log(postParams);
this.http.post("http://pro-apps.net/steps-me/api/product_watched", postParams, options)
.subscribe(data => {
console.log(data['_body']);
this.notification.watched++;
}, error => {
console.log(error);// Error getting the data
});
}
}
my html page:
Details of New {{notification_type}}what is the rong ?
thank you for helping and i am sorry for my english lanauge