1

I cannot seen to be able to load in a json image if the key value is a number, it doesn't seem to matter if I call it in html text or ascii.

Here I use two different key foo and 200x150 that have the same image value

json:

$scope.items = [
       {
          "id": 1,
          "name": "Location 1",
          "items_image": {
            "id": 101,
            "image": {
              "200x150": "http://placehold.it/200x150?text=num1",
              "foo":     "http://placehold.it/200x150?text=foo1"
            }
          }
        }

loading foo as "foo": works

<img ng-src="{{item.items_image.image.foo}}">

loading foo as "&#102;&#111;&#111;": works

 <img ng-src="{{item.items_image.image.&#102;&#111;&#111;}}">

loading 200x150 as "200x150": fails

<img ng-src="{{item.items_image.image.200x150}}">

loading 200x150 as "&#50;&#48;&#48;&#120;&#49;&#53;&#48;": fails

<img ng-src="{{item.items_image.image.&#50;&#48;&#48;&#120;&#49;&#53;&#48;}}">

How do I do this with numbers? I included an example: http://codepen.io/garrettmac/pen/wKOmoP

1
  • Can you use array notation? items.items_image.image['200x150'] -- I'm not sure if JavaScript object keys can begin with a number, but it's apparently valid JSON. Commented Nov 19, 2015 at 3:17

1 Answer 1

1
<img ng-src="{{item.items_image.image['200x150']}}">
Sign up to request clarification or add additional context in comments.

Comments

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.