Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

Your factory has to return something. It's the return value that's injected:

myApp.factory('myDataService', ['$http', function($http){
 
   var myDataService = {};
   myDataService.getData = function() {
        ...
  })
    return myDataService;
};

More on Angular factoriesAngular factories

Your factory has to return something. It's the return value that's injected:

myApp.factory('myDataService', ['$http', function($http){
 
   var myDataService = {};
   myDataService.getData = function() {
        ...
  })
    return myDataService;
};

More on Angular factories

Your factory has to return something. It's the return value that's injected:

myApp.factory('myDataService', ['$http', function($http){
 
   var myDataService = {};
   myDataService.getData = function() {
        ...
  })
    return myDataService;
};

More on Angular factories

deleted 285 characters in body
Source Link
Michael Kang
  • 53k
  • 16
  • 108
  • 138

Your factory has to return something. It's the return value that's injected:

myApp.factory('myDataService', ['$http', function($http){
 
   var myDataService = {};
   myDataService.getData = function() {
 
    $http.get('/api/reviews')
    .success(function(data, status, headers, config) {

        console.log("Data received");
        return data;

    })
    .error(function(data, status, headers, config) {
        console.error("No data received");
    })
    return myDataService;
};

More on Angular factories

Your factory has to return something. It's the return value that's injected:

myApp.factory('myDataService', ['$http', function($http){
 
   var myDataService = {};
   myDataService.getData = function() {
 
    $http.get('/api/reviews')
    .success(function(data, status, headers, config) {

        console.log("Data received");
        return data;

    })
    .error(function(data, status, headers, config) {
        console.error("No data received");
    })
    return myDataService;
};

More on Angular factories

Your factory has to return something. It's the return value that's injected:

myApp.factory('myDataService', ['$http', function($http){
 
   var myDataService = {};
   myDataService.getData = function() {
        ...
  })
    return myDataService;
};

More on Angular factories

added 143 characters in body
Source Link
Michael Kang
  • 53k
  • 16
  • 108
  • 138

Your factory has to return something. It's the return value that's injected:

myApp.factory('myDataService', ['$http', function($http){
 
   var myDataService = {};
   myDataService.getData = function() {

    $http.get('/api/reviews')
    .success(function(data, status, headers, config) {

        console.log("Data received");
        return data;

    })
    .error(function(data, status, headers, config) {
        console.error("No data received");
    })
    return myDataService;
};

More on Angular factories

Your factory has to return something. It's the return value that's injected:

myApp.factory('myDataService', ['$http', function($http){
 
   var myDataService = {};
   myDataService.getData = function() {

    $http.get('/api/reviews')
    .success(function(data, status, headers, config) {

        console.log("Data received");
        return data;

    })
    .error(function(data, status, headers, config) {
        console.error("No data received");
    })
    return myDataService;
};

Your factory has to return something. It's the return value that's injected:

myApp.factory('myDataService', ['$http', function($http){
 
   var myDataService = {};
   myDataService.getData = function() {

    $http.get('/api/reviews')
    .success(function(data, status, headers, config) {

        console.log("Data received");
        return data;

    })
    .error(function(data, status, headers, config) {
        console.error("No data received");
    })
    return myDataService;
};

More on Angular factories

Source Link
Michael Kang
  • 53k
  • 16
  • 108
  • 138
Loading