Created factory that will return json data and calling it from controller, but it is coming empty. don't know where I made mistake. no console error and in network json 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();
}
}]);