0

I got empty data when I'm trying to read image data from the JSON file. I don't know what is missing. I have been writing this as a single file and it's work properly but when I'm using it with other files it's show nothing.

HTML

<body ng-app="myApp" ng-controller="myCtrl">
  <div>
    <div>
      <div class="banner">
        <ul id="lightSlider">
          <li ng-repeat="image in images"><img ng-src="{{image.img}}"></li>
        </ul>
      </div>
    </div>
  </div>

JS

var app = angular.module('myApp', ['ui.router']);
app.controller('myCtrl', ["$scope", "$http", "$timeout" function($scope, $http, $timeout) {
  $http.get('image.json')
    .success(function(data, status, header, config) {
      $scope.images = data.items;
    })
  $timeout(function() {
      $("#lightSlider").lightSlider({
        item: 1,
        auto: true,
        loop: true,
        speed: 1000,
        pause: 3000,
      });
  },0)
}]);
La Cooler
  • 23
  • 1
  • 7
  • There is no point of the `.ready` functions inside a controller. The AngularJS frame work never instantiates a controller before the `DOMContentLoaded` event. Nesting a jQuery `.ready` inside a jqLite `.ready` inside a controller is just silly. – georgeawg Jul 09 '19 at 05:37
  • The `.success` method has been [removed from the AngularJS framework](https://stackoverflow.com/questions/35329384/why-are-angularjs-http-success-error-methods-deprecated-removed-from-v1-6/35331339#35331339) – georgeawg Jul 09 '19 at 05:40
  • What should I do with this so? – La Cooler Jul 09 '19 at 06:12
  • I have updated my code with $timeout @georgeawg – La Cooler Jul 09 '19 at 07:01

0 Answers0