1
如果key值是一個數字,我看不到能夠加載json圖像,如果我用html文本或ascii調用它,似乎並不重要。如何加載角度設置爲字符串的JSON數值?
這裏使用了兩個不同的密鑰foo
和200x150
具有相同的圖像值
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"
}
}
}
裝富的 「富」:工作
<img ng-src="{{item.items_image.image.foo}}">
將foo加載爲「foo
「:工作
<img ng-src="{{item.items_image.image.foo}}">
裝載200x150爲 」200x150「:失敗
<img ng-src="{{item.items_image.image.200x150}}">
裝載200x150爲」 200x150
「:失敗
<img ng-src="{{item.items_image.image.200x150}}">
我該怎麼辦這與數字?我列舉了一個例子:http://codepen.io/garrettmac/pen/wKOmoP
你可以使用數組表示法嗎? 'items.items_image.image ['200x150']' - 我不確定JavaScript對象鍵是否可以以數字開頭,但它顯然是有效的JSON。 – Blazemonger