[CODE]
export class page1 {
private storage: Storage;
public personList: Array<Object>;
public constructor(private navCtrl: NavController) {
this.storage = new Storage(SqlStorage);
this.storage.query("CREATE TABLE IF NOT EXISTS people (id INTEGER
PRIMARY KEY AUTOINCREMENT, firstname TEXT, lastname TEXT)");
this.personList = [];
}
public onPageLoaded() {
this.refresh();
}
public add() {
this.storage.query("INSERT INTO people (firstname, lastname) VALUES
(?, ?)", ["Nic", "Raboy"]).then((data) => {
this.personList.push({
"firstname": "Nic",
"lastname": "Raboy"
});
}, (error) => {
console.log(error);
});
}
public refresh() {
this.storage.query("SELECT * FROM people").then((data) => {
if (data.res.rows.length > 0) {
this.personList = [];
for (let i = 0; i < data.res.rows.length; i++) {
this.personList.push({
"id": data.res.rows.item(i).id,
"firstname": data.res.rows.item(i).firstname,
"lastname": data.res.rows.item(i).lastname,
});
}
}
}, (error) => {
console.log(error);
});
}
}
[/CODE]
i searched in google bt unable to solve this.
--
You received this message because you are subscribed to the Google Groups
"Angular" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.