I am attempting to build a SPA using VF, AngularJS and numerous Custom Apex Controllers with RemoteActions. My plan was to call the Apex backend via Javascript Remoting calls wrapped in Angular Services.

I have read, and re-read through the docs and I am still a bit fuzzy on something: Do you have to explicitly inject a controller in the page component in order to use it for remoting?

1 Answer 1



global  class xGlobal {
    global static string doAction1( string JSONData ) {  
    return class1.doAction(JSONData );
    global static string doAction2( string JSONData ) {  
    return class2.doActionElse(JSONData );


// component

<apex:component controller="iQuoteGlobal">
    <script type="text/javascript">
 var xCorpNS = new Object();
 xCorpNS.doAction1= '{!$RemoteAction.xGlobal.doAction1}';
 xCorpNS.doAction2= '{!$RemoteAction.xGlobal.doAction2}';

In my application I have one component tied to one global class for all remote actions. I add the component to the pages that require remote actions.

The global class methods are small and all the real work is performed in different sub classes.

Helps separate the business logic from the mechanics of configuring remote actions.

  • Interesting. Didn't think to use components. I ended up converting the remoting classes to extensions and adding them to me main VF page. However, it requires me to upkeep the list of Apex Class extensions and redeploy the VF page.
    – tagCincy
    Commented Apr 4, 2015 at 16:40
  • It really depends on where you go with remotes. In SF you basically have standard pages with post backs, submits with rerender blocks, and remotes call backs. It gets complicated when you try to mix the first two with remotes. Where I have ended up is that for key pages I am "All in" and render with VF but no standard post backs and everything is JSON back to the controller. It is way too messy trying to do both techniques on the same page and its much more fluid and easier to understand. That's when the architecture becomes important.
    – Bruce
    Commented Apr 6, 2015 at 9:31
  • In addition to using components, i place all javasscript in separate file with prototype name spaces to perform the remote calls and handle responses. No javascript directly in pages and simply link the javascript in the component itself not the pages.
    – Bruce
    Commented Apr 6, 2015 at 9:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .