I have data in angularjs factory that is dataSource for kendo grid , i also want to get raw data object to write some logic but i am not able to populate data object from the factory to controller, console.log
is printing the data in factory. How can i get json object in controller using 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;
}
});
Return data from service
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);
return data
}).error(function(err) {
console.log(err);return;
});
}
},
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.