Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8877301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:26:08+00:00 2026-06-14T19:26:08+00:00

I am new to Angular JS and really struggling to get data into my

  • 0

I am new to Angular JS and really struggling to get data into my controller from javascript remoting. Has anyone done this before?

Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.Forecasting.Users}',
  new Object(),function(result, event){
    return result
  }
);

How on earth do i get the data into the controller :

var forecastingCtrl = function($scope, $q){
    $scope.lengths = function(){return '5'};
    $scope.users = [];
}

EDIT : Following works fine:

fc.service('Users', function($rootScope, $q) {
    this.get = function(){
        var deferred = $q.defer();

            Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.Forecasting.Users}',new Object(),function(result, event){
                if(event) {
                     $rootScope.$apply(function() {
                        deferred.resolve(result);
                    });

                } else { 
                    deferred.reject(result);
                }            
            });
            return deferred.promise;

    }

});

function forecastingCtrl($scope, $q, Users){
    $scope.lengths = function(){return '5'};


    var promise = Users.get();
    promise.then(
        function(users){
            $scope.users = users;
        },
        function(reason){
            alert('Failed: ' + reason);
        }
    );    

};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:26:10+00:00Added an answer on June 14, 2026 at 7:26 pm

    I haven’t used javascript remoting (sounds interesting) but what you will probably want to do is to encapsulate your visualforce code inside a service, having a method (most likely a promise) to return your data and inject the service into your controller. The upside of this is that you can unit test your controller by injecting a mock or spy of your data service. The pattern would be very much like how you would use angular’s $http and $resource services. Hopefully this gets you on the right track.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New to PHP and MySQL, have heard amazing things about this website from Leo
new AjaxOptions { OnBegin = MyFunction, Url=/Controller/JSONAction/+OnbeginRetunrValue, HttpMethod=GET } In my Ajax properties, I
I am new to Angular and Flot, but am experienced with Jquery and Javascript.
I'm trying to learn AngularJS. My first attempt to get new data every second
The app runs but Angular data objects are not recognized. Here is the JavaScript
New to Regex. I want to validate to this format: Any character allowed, except
New programmer here, I am trying to understand and break down this code below
I am new to angular, I want to know if angularjs supports nested routes
I use Angular $resource for REST service. Due to the quirk in my get
Is it possible to have one controller use another? For example: This HTML document

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.