0

Json file:

{
"id":"7",  
"date":"1 Jan",  
"images":["507f42c682882","507e24b47ffdb","507e2aeca02d5","507e2b19663a9"]  
}

in my controller I have

$http.get('urlToJsonFile).
    success(function(d){
        console.log(d);
        $scope.item = d;
    });

in my partial view I can print the id and date but when it comes to printing the images, it just doesnt work. Im doing it wrong. Why isnt there any output? Do you know how to fix this problem?

{{item.id}}:{{item.date}}
    <ul>
    <li ng-repeat="img in item.images">
    {{img}}
    </li>
    </ul>

2 Answers 2

1

It's working. See This JS Fiddle . Can you put your code in JSFiddle as to why it's not working for you ?

I've used your ajax response as hard coded collection.

'use strict';

var obj = {
    "id": "7",
    "date": "1 Jan",
    "images": ["507f42c682882", "507e24b47ffdb", "507e2aeca02d5", "507e2b19663a9"]
};

function Ctrl($scope) {
    $scope.item = obj;
}​
Sign up to request clarification or add additional context in comments.

Comments

1

There are some known issues with ng-repeat and iterating over primitive types. Check this issue on github .

If possible, try to use objects as your array elements.

Comments

Your Answer

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