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

  • SEARCH
  • Home
  • 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 8921827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:39:35+00:00 2026-06-15T06:39:35+00:00

In the wire up a backend demo code from the angularjs site they set

  • 0

In the “wire up a backend” demo code from the angularjs site they set up a db call. From what I can tell they’re extending the update function in order to add some extra parameters needed by the mongolab api.

angular.module('mongolab', ['ngResource']).
factory('Project', function($resource) {
  var Project = $resource('https://api.mongolab.com/api/1/databases' +
      '/angularjs/collections/projects/:id',
      { apiKey: '4f847ad3e4b08a2eed5f3b54' }, {
        update: { method: 'PUT' }
      }
  );

  Project.prototype.update = function(cb) {
    return Project.update({id: this._id.$oid},
        angular.extend({}, this, {_id:undefined}), cb);
  };

Then they call the update property like this:

$scope.save = function() {
$scope.project.update(function() {
  $location.path('/');
});

I’ve tried using this code to build a demo app using a local development server so I’ve omitted extending the update property as I don’t need the extra $oid parameter. What I do need is to specify that the update method should use PUT. My code is like this:

var Unit = $resource('http:/localhost/api/unit/:id', {id:'@Unit_Id'},
{'update': { method: 'PUT' }}); 

And then calling it like this:

$scope.save = function () {
    $scope.unit.update(function () {
        $location.path('/unitlist');
    });

But What I’ve discovered is that the code only runs with a dollar sign in front of update like this:

    $scope.save = function () {
    $scope.unit.$update(function () {
        $location.path('/unitlist');
    });

So here are my questions:

  1. In the demo code, where is “update” actually added to the Project variable? As a parameter in $resource or using prototype to extend Project?
  2. Why is update undefined in my code unless I prefix $ when I call it?
  • 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-15T06:39:36+00:00Added an answer on June 15, 2026 at 6:39 am

    Ok, here it is from the docs

    The action methods on the class object or instance object can be
    invoked with the following parameters: HTTP GET “class” actions:
    Resource.action([parameters], [success], [error]) non-GET “class”
    actions: Resource.action([parameters], postData, [success], [error])
    non-GET instance actions: instance.$action([parameters], [success],
    [error])

    So, when you when you extend the class (prototype), call it without the $ like normal, but when you add an action as a parameter of $resource prefix $.

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

Sidebar

Related Questions

Using Spring 3.0 EL can we auto wire a property from a property file
I'm trying to wire up Windsor 3.0 to inject connection strings from my web.config
I am using AddHandler to wire a function to a control's event that I
how i can delete this wire lines that devide my prism on triangles? http://img217.imageshack.us/img217/1535/31477485.jpg
In my code behind I wire up my events like so: protected override void
I've noticed recently that spring can wire up my ejb's for me if I
I am trying to interface a 4-wire resistive touchscreen to a PIC24FJ256 from Microchip.
I'm trying to wire up Spring Data JPA objects manually so that I can
Is there any way I can wire up an attached behavior based on the
So using some assistance from tutorials I have managed to wire up a Nhibernate

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.