Reputation: 281
function CadError($http) {
// Return the object
return {
// Create simple method to get data from $http service
getFullList : function() {
return $http({
url: 'URL',
method: 'GET'
})
}
}
}
function LogError($http) {
// Return the object
return {
// Create simple method to get data from $http service
getFullList : function() {
return $http({
url: 'URL',
method: 'GET'
})
}
}
}
angular
.module('inspinia')
.factory('CadError', CadError);
I am wondering how to implement two data sets in a single factories.js file. I am able to load the first data set called cad error but I have not been able to load the second set log error data. I had added another line at the bottom .factory('LogErrorData',LogErrorData);
However that broke the first cad error so I removed it. Any help would be appreciated. If you need more code I can provide that.
controller.js
function caderror($scope, CadError) {
// Run method getFullList() from factory
myFac.getFullList().success(function(data){
// Assign data to $scope
$scope.dataFromFactory = data;
});
}
function logerror($scope, LogError) {
// Run method getFullList() from factory
myFac.getFullList().success(function(data){
// Assign data to $scope
$scope.dataFromFactory = data;
});
}
Upvotes: 0
Views: 82
Reputation: 17494
angular
.module('inspinia')
.factory('myFac', function($http){
return {
CadError : function() {
return {
// Create simple method to get data from $http service
getFullList : function() {
return $http({url: 'URL',method: 'GET'})
}
}
},
LogError: function() {
return {
getFullList : function() {
return $http({url: 'URL',method: 'GET'})
}
}
}
}
});
CONTROLLER.JS
function caderror($scope, myFac) {
// Run method getFullList() from factory
myFac.CadError().getFullList().success(function(data){
// Assign data to $scope
$scope.dataFromFactory = data;
});
}
function logerror($scope, myFac) {
// Run method getFullList() from factory
myFac.LogError().getFullList().success(function(data){
// Assign data to $scope
$scope.dataFromFactory = data;
});
}
Upvotes: 1