@littlefloralbunny wrote:
Hello there!
I am building an app in which I store and retrieve items from a device’s local storage using the ionic storage package. I have no problems with storing items, but I am having trouble with retrieving the stored values and using them as a variable.
For example, say I have this item in storage:
person = { name: "Angela", age: "32" } this.storage.set("01", person);
I want to get this item from storage and display it to a html page like so:
<p> {{ person.name }} </p> <p> {{ person.age }} </p>
To do this, I would need to assign it to a variable called “person” when the page loads.
If I were to usethis.person = this.storage.get("01")
, I have a blank page.
If I usethis.storage.get("01").then(item => (this.person = item))
, this.person is undefined.How can I get the value of the stored item and assign it to a class variable?
Thanks in advance
Posts: 1
Participants: 1