Closed marioshtika closed 8 years ago
You can easily load images from a json file. Make $http call from controller for the json file and assign the result to items.
I am doing this:
$http.get('gallery.json').then(function (result) {
$scope.photos = result.data;
console.log($scope.photos);
}, function (err) {
console.log(err);
});
but it still doesn't load them.
The error logs is: "TypeError: Cannot read property 'length' of undefined"
I think the directive doesn't wait for the controller to load the json data.
Is that right? Is there a way to make it work?
I have faced this issue. Use $scope.photos = [ ]
before making the http call
You are the best :)
I can't believe it was that simple.
Thank you very much.
This is actually a stupid bug the directive has (and I've been meaning to fix that). You can't pass to the directive an undefined array for items
Hello and congratulation for this great directive.
I want to ask is there a way to load images from a json file and not inside the controller.
If I do so, i think it doesn't load the json file in time to show it.
Can you help me with this?
Thank you in advance.