Developed a factory that returns JSON data and calling it from the controller, but the data is returning empty. I'm not sure where I went wrong. There are no console errors and in the network tab, the JSON data is also loading.
'use strict';
var app = angular.module('angularJson', ['ngResource']);
app.factory('loadJsonService', ['$resource', function ($resource) {
return {
getData: function () {
return $resource('json/productDetails.json');
}
};
}])
app.controller('angularJsonCtrl',['$scope', 'loadJsonService',function($scope, loadJsonService){
$scope.loadProducts = function(noOfData){
$scope.productDetails = [];
$scope.productDetails = loadJsonService.getData().query();
}
}]);