Controller not returning data from factory

Controller not returning data from factory

By : user2949773
Date : November 17 2020, 04:28 AM
To fix this issue Imagine a prison with prisoners in separate cells, and I want to be able to be able to access a specific cell by calling the API '/getparameters' that will return the cell number, and then pass that variable in as the id for my factory. This is what I have come up with. No error are returned, but no data is being returned either. Where am I going wrong? , You've got your parentheses in the wrong places:
code :
CellID.get({id:cellnumber}), function(data){
    $scope.info = data;
CellID.get({id:cellnumber}/* <-- no parenthesis here */, function(data){
    $scope.info = data;
}); // <-- parenthesis here (and a semicolon)
$scope.info = CellID.get({id:cellnumber});

Share : facebook icon twitter icon
How to handle IController Factory not returning a controller for the request

How to handle IController Factory not returning a controller for the request

By : Shk Rabi
Date : March 29 2020, 07:55 AM
wish helps you Unfortunately, the best solution I found was to revert from Asp.net MVC 4 to Asp.net MVC 3, in which the Ninject.Web.MVC assembly completely handles all of this for you.
Though this may be an unacceptable answer for some, it helped solve my issue.
Requesting data from factory and returning data back to same factory for sharing between controllers

Requesting data from factory and returning data back to same factory for sharing between controllers

By : Ibrahim Abdullah Alr
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , You can update Products.details.current directly from your getProducts function. If getProduct can be called from different places in your app and you want to keep the info in sync within your controller, you can use a $watch.
code :
    .factory('Products', function($http, ENV){
        var Products = {};

        Products.details =
            //grabs the most current endpoint and creates a session of that data
            current: {},
            getProduct: function($scope, productId) {
                return $http.get(ENV.apiEndpoint + '/v2/listings/' + productId + '.json')
                        Products.details.current = data; // Update 
                        return data;
                    .error(function(data, status){
                        console.log('error:' + status);


        return Products;

    .controller('MainCtrl', function($scope, Products) {
        $scope.product = Products.details.current;
        var handleProductSuccess = function (data) { // (not required if you use the watch below)

            // stores the data for the current controller

            $scope.product = data;
        //on click of a product from view
        Products.details.getProduct($scope, $scope.productId)

        // If another scope can modify Products.details.current and you want to watch for it:
            function () { return Products.details.current;},
            function (newVal) { $scope.product = newVal; },
Angular factory not returning value to controller

Angular factory not returning value to controller

By : Abdullah Fahad
Date : March 29 2020, 07:55 AM
this will help Your service method socket.switchSpace() does not return a promise (or, as you have implemented it in your controller, an object with a $promise property).
So in order to make this work, you need to:
code :
.factory('socket', function (socketFactory, $q) {

  var connection = io.connect('http://example.com:3000');

  var socket = socketFactory({
    ioSocket: connection

  socket.switchSpace = function(spaces) {
    var deferred = $q.defer();

    socket.emit('leaveSpace', spaces.oldspace, function(callback) {
      if(callback == 'success') {
        socket.emit('joinSpace', spaces.newspace, function(callback) {
          if(callback == 'success') {

    return deferred.promise;

  return socket;
.controller('SettingsCtrl1', function($scope,socket) {
    socket.switchSpace(spaces).then(function(data) {
      alert("CALLBACK: " + data);
factory not returning object in controller

factory not returning object in controller

By : Vadim Sukharev
Date : March 29 2020, 07:55 AM
hope this fix your issue u can catch the promise from controller instead of the factory. just return the jsonQueryStations.stationData() only in factory.
code :
mainApp.factory('statusFinder', ['jsonQueryStations', 'timeConverter', function(jsonQueryStations, timeConverter){
   var generator = function(){
      return jsonQueryStations.stationData()
   return {
    status: function(){
      return generator();
mainApp.controller('stuff', ['$scope', 'statusFinder', function($scope, statusFinder) {
    var findTheTime = timeConverter.getTime();
    statusFinder.status().then(function(result) {
        if (result.station[findTheTime] > result.station.Average) {
            $scope.testing = "Station is busy";
        } else {
            $scope.testing = "Station is quiet";
Returning data from the factory to the controller

Returning data from the factory to the controller

By : imran hossain
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Use below syntax in controller. The reason your code not working is you have written a service called Users.activeDeactive, you are calling it from the controller but not waiting for the response. Its very important to wait for the response. If the service call is successful, it will execute then part. Here you need to catch the response like in given syntax only. In case of errors, it will go to the error part.
code :
    ;(() => {
    app.controller('UsersCtrl', usersCtrl);

    function usersCtrl($scope, $state, Users, users, vendors, profiles, clients) {
       Users.users = users;
       $scope.activeDeactive = function(userId, activate) {
          Users.activeDeactive(userId, activate).then(function(data){
      response = data;


Related Posts Related Posts :
  • How to debug Vue application with google chrome
  • html 5 web app cache download complete javascript alert?
  • Ember.js setupController fired only once
  • How to validate a currency input
  • How to convert my Array of data to key & value pair
  • Statistics circles in CSS
  • So I wanted to make a trig solver in javascript?
  • Showing HighCharts series name on x-axis and in legend
  • In Rails, how can we pass parameters in script?
  • Build Fails: `npm rebuild node-sass --force`
  • Angular Datepicker change dateformat
  • Trying to extract data from between two sets of characters
  • Configuring Jest in WebStorm
  • Uncaught Error: Syntax error, unrecognized expression: tr.ec_portfolio_title,
  • JQuery fading in fading out continuously
  • Unexpected end of input (Line 1) and Undefined Function?
  • How to animate the width of a div slowly with jquery
  • JavaScript + RegEx Complications- Searching Strings Not Containing SubString
  • SignalR - Unable to get property 'client' of undefined or null reference
  • full calendar not displaying when loaded (with backbone)
  • Angular: Update service and share data between controllers
  • ReplaceAll Google script
  • Search for matching LI items in separate UL
  • Access arguments of an... argument
  • Customizing Google custom search jsapi (query strings)
  • React | Can´t load Images > Module not found
  • Dynamically creating buttons in DOJO
  • 404 Not Found in AJAX post call
  • How do I find out, using javascript, what software opened and running my application?
  • Javascript to check the status of wireless connection
  • StarDict support for JavaScript and a Firefox OS App
  • Phonegap event Resume
  • call javascript function on ENTER key press?
  • When is the best time to remove no-js classes from the html tag
  • Recommended email sending languages
  • setInterval not working properly with chrome
  • Does IE create new scope for each script tag?
  • Uncaught SyntaxError: Unexpected token < Underscore and parse issues
  • How to pass captured URL to Email Body in HTML
  • How to structure default nested resources?
  • Store all the keys of a JSON object in a variable
  • Need an efficient way to group the Array of object in javascript
  • a sensible approach to highcharts x-axis labels
  • IDE autocompletion for javascript AMD loading style
  • Bootstrap menu disappears after first click setting the ul style to none
  • split ajax json response errors in each field
  • how to add javascript in head in cmsms
  • REGEX: Finding the correct occurrence order of some given special characters in a string
  • How do you preserve a JavaScript date's time zone from browser to server, and back?
  • Return binary result from phantomjs webserver
  • must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.
  • Replacing a substring of an element's text with another string
  • How do I filter marks greater than or equal to 90 in this array?
  • Modify the text of my radio input button?
  • Clicking on status bar does not scroll to top of app (Trigger.io)
  • Mocha JS: How to highlight specific assertion failure?
  • $.getJSON jquery parsing to HTML
  • Find items of a certain class (a) that are also in other classes (b,c,d)
  • Setting different images for D3 force-directed layout nodes
  • Integrating Dropzone.js with angular
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org