0

I am pulling some user profile data from the database and storing it in an observable. I can access properties with typing profileData.username,profileData.msgnumber etc...

profileData.avatar returns the name of avatar user is using. What I'm trying to do is if profileData.avatar equals "bear" display bear picture in HTML or if it equals "spider" display spider in HTML. Now I can display just string by writing {{profileData.avatar}}

1
  • what have you tried so far? give some example JSON for profileData Commented Oct 26, 2017 at 10:18

1 Answer 1

1

In ionic 2 you need to write something like,

<ion-item>
 <ion-avatar>
  <img src=" {{profileData.avatar}}">
 </ion-avatar>
</ion-item>
Sign up to request clarification or add additional context in comments.

2 Comments

im not holding avatars with urls.they are just strings. like avatar:"bear" is there any other way ?
Just a string 'bear' will not work for getting image and display it in html file. Absolute or relative any path of image would be needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.