Ionic: Adding images from JSON file?


#1

I’m trying to load an image from a JSON file into my ionic application.

I can load messages/strings from the JSON file but can’t get images to work.

Here’s my JSON file: http://wikicode.co.uk/file.json
acc
I’m trying to load ‘source’ link but it isn’t working.

Here’s my code:

HTML:

<img class="full-image" src="{{item.source}}">

Javscript:

.controller('announcementCtrl', function($scope, $http) {
  $scope.data = [];
  $scope.infiniteLimit = 1;

  $scope.doRefresh = function() {
    $http.get('http://wikicode.co.uk/file.json')
      .success(function(data) {
        $scope.data = data;

        $scope.$broadcast('scroll.refreshComplete');
      })
      .error(function() {
        $scope.data = [];

        $scope.$broadcast('scroll.refreshComplete');
      });
  }

#2

Please use ng-src in your template
https://docs.angularjs.org/api/ng/directive/ngSrc


#3

Solved it. Turns out i wasn’t referencing the images correctly.