0

I have the following JS code:

{var c;a.stores=[{name:"Nijiya Market",price:"$$",sales:292,rating:4},{name:"Eat On Monday Truck",price:"$",sales:119,rating:4.3}]

I call on these variables to produce an html table. What I want to do is use html within the JS variable to produce an image instead of text. So for example:

{var c;a.stores=[{name:"<img src='url'>",price:"$$",sales:292,rating:4},{name:"<img src='url'>",price:"$",sales:119,rating:4.3}]

Can anyone suggest how I do this and if the same method would work with php.

Don't know if it matters, but I am using AngularJS.

Thanks.

5
  • That should work fine if you're just gonna display it on a html page, have you tried it? Commented May 6, 2015 at 3:02
  • @ChrisEvans yes. It just appears as <img src='url'> see image: s24.postimg.org/85vg1sx3p/… Commented May 6, 2015 at 3:05
  • you should have name: "<img src='" + url + "'>" Commented May 6, 2015 at 3:10
  • @ChrisEvans that just causes it to error and the page to not load. Commented May 6, 2015 at 3:15
  • 1
    need to use ng-bind-html to pass <img> to template because it isn't text. Angular expressions only take text. But would make more sense to just send the url and use ng-src in an image tag within the template. Suppose you wanted a css class later on the images...would only need to add it once in template and not have to update your database or php or whatever is now creating that <img> Commented May 6, 2015 at 3:59

0

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.