I am trying to access raw data object from an angularJS factory that serves as a dataSource for a kendo grid. Despite being able to console log the data in the factory, I'm facing difficulty populating the data object in the controller. How can I retrieve a JSON object in the controller using the same angularJS factory?
factory.js
angular.module('App').factory('processService', function($http, $stateParams, OrcitLoader) {
'use strict';
getPrcChallengesGridDataSource: function(processKey, challengeType) {
return new kendo.data.DataSource({
type: 'json',
transport: {
read: function(options) {
return OrcitLoader.load($http.get('app/challenge/rest/getChallengesForGrid?key=' + processKey + '&challengeType=' + challengeType)).success(
function(data) {
console.log(data);
options.success(data);
}).error(function(err) {
console.log(err);
});
}
},
});
Controller.js
angular
.module('App')
.controller('ProcessCtrl', function($scope, processService) {
processService.getPrcChallengesGridDataSource($stateParams.processId,challengeTypeLkupCode).then(function(response) {
var data = response.data;
}
});