I have a code that uses to load data passing from the sever side into a jQGrid. I'm using an AngularJS factory method to initiate the call and return received json document. I'm getting Uncaught TypeError: Cannot read property 'loadDataToGrid' of undefined
error in chrome console.
JQuery function to load data into jQGrid :-
$(function ($scope,$http,$rootScope,retriveDataFromServer) {
$("#list").jqGrid({
url: retriveDataFromServer.loadDataToGrid($http),
datatype: "json",
mtype: "GET",
colNames: ["Employee First Name", "Employee Last Name", "Contact No"],
colModel: [
{ name: "fname", width: 55 },
{ name: "lname", width: 60 },
{ name: "contactNo", width: 55, align: "right" },
],
pager: "#pager",
rowNum: 10,
autowidth: true,
rowList: [10, 20, 30],
sortname: "fname",
sortorder: "desc",
viewrecords: true,
gridview: true,
autoencode: true,
caption: "Employee Data Grid"
});
});
AngulaJS factory method :-
empApp.factory('retriveDataFromServer',function(){
return{
loadDataToGrid: function($http){
return $http({
method : 'GET',
url : 'http://localhost:8080/IdeaOne/viewall'
}).then(function(response){
return response;
})
}
}
});
html :-
<div ng-app="empApp">
<table id="list"><tr><td></td></tr></table>
<div id="pager"></div>
</div>
when I directly load my data by specifying my url inside jQuery method it works fine.
Someone please point out where did I go wrong.