Here is the background info that I’m using:
ionic - v2.2.1
node - v6.9.5
cordova - v6.5.0
I have successfully retrieved my object via SQLite in the .ts file.
=======================================
@Component({
selector: ‘page-field-info’,
templateUrl: ‘field-info.html’
})
export class FieldInfoPage {
field: any;
client: any;
crop: any;
constructor(public navCtrl: NavController, public navParams: NavParams, public modalCtrl: ModalController, public database: Database) {
this.field = navParams.get('field');
this.database.getClientById(this.field.clientId).then((result) => {
if(result != null) {
this.client = result;
console.log("@@@ LOG::field-info.ts: ");
console.log(this.client);
}
}, (error) => { console.log("ERROR::FieldInfoPage::getClientById: ", error); });
this.database.getCropTypeById(this.field.cropId, "en").then((result) => {
if(result != null) {
this.crop = result;
}
}, (error) => { console.log("ERROR::FieldInfoPage::getCropTypeById: ", error); });
}
=======================================
On my html, I just try to reference it, but it seems to be undefined.
Here is my html page reference.
<ion-content padding class="body">
<ion-card>
<ion-card-header><h1>Field Information</h1></ion-card-header>
<ion-card-content>
<p>Client: {{client.clientId}}</p>
<p>Client Rep: {{client.name}}</p>
<p>{{field.desc}}</p>
</ion-card-content>
</ion-card>
</ion-content>
===========================================
Here is the log I received.
@@@ LOG::getClientById:: SQL = SELECT DISTINCT * FROM CLIENT WHERE CLIENT_ID = 1 main.js:18842 database already open: data.db SQLitePlugin.js:168 @@@ LOG::ionViewDidLoad: Client: main.js:57833 undefined main.js:57834 @@@ LOG::getAllClients::Returned rows = 1 main.js:18860 No rows affected! main.js:18873 @@@ LOG::field-info.ts: main.js:57811 Object {clientId: 1, name: "Mr. Jenkins", company: "Happy Farms"}
Am I missing something? I was under the impression if I got the object in the ts file, I should be able to access it on my html; however, I’m confused as why it’s not working.
thank you for your time in advance.