I'm completely new to typescript and Angular 2 and I'm having some trouble trying to output to a page within a Cordova / Angular app.
Page ( book.html ):
<ion-header>
<ion-navbar>
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Book</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<h3>Book</h3>
<p>
Book page.
</p>
<p>
<span>{{ oBookingDebug }}</span>
</p>
</ion-content>
Code ( book.ts ):
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { InAppBrowser } from '@ionic-native/in-app-browser';
@Component({
selector: 'page-book',
templateUrl: 'book.html'
})
export class BookPage {
public oBookingDebug: string = "";
constructor(public navCtrl: NavController, public iab: InAppBrowser) {
this.oBookingDebug="TEST"; // <-- WORKS AND SHOWS ON THE PAGE!!
const browser = this.iab.create('http://**');
browser.on("loadstop")
.subscribe(
() => {
browser.executeScript(
{
code:'localStorage.getItem("bookingObject");'
}).then(
(oBooking)=>{
alert(oBooking); // Test
this.oBookingDebug="DAVE"; // <-- DOESNT WORK!!
});
},
err => {
console.log("InAppBrowser Loadstop Event Error: " + err);
});
}
}
If you look at my comments you can see what works and what doesn't, how do I access the page to output from within the executescript callback, id like to be able to display to the page at this point but also assign to a variable for later access too.