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 8147887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:30:18+00:00 2026-06-06T14:30:18+00:00

Instead of posting in Angular mailing list, I think this may be more of

  • 0

Instead of posting in Angular mailing list, I think this may be more of javascript question. Hope the SO community can also give faster response.

I am trying to encapsulate the data in a service and injecting into controller.

angular.module('myApp.services', ['ngResource']).
    factory('Player', function($resource){
        var Player ;
        Player = {
            resource: $resource('/api/Player/:_id', {} )
        };
        return Player
});


function PlayerDetailCtrl(Player, $routeParams, $scope) {
    $scope.resource = Player.resource.get({_id:$routeParams._id});
}
PlayerDetailCtrl.$inject = ['Player', '$routeParams', '$scope'];

It throws an exception

TypeError: Object #<Object> has no method 'query'

$scope.resource = Player.Player.resource.get({_id:$routeParams._id}); also throws error

TypeError: Object #<Object> has no method 'query'

the below works.

angular.module('myApp.services', ['ngResource']).
    factory('Player', function($resource){
        var Player ;
        Player= $resource('/api/Player/:_id', {} )
        return Player
});


function PlayerDetailCtrl(Player, $routeParams, $scope) {
    $scope.resource = Player.Player.get({_id:$routeParams._id});
}
PlayerDetailCtrl.$inject = ['Player', '$routeParams', '$scope'];

my intention is to add more data and method to Player. So how can I make the first (object form) works!

  • 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-06T14:30:21+00:00Added an answer on June 6, 2026 at 2:30 pm

    You are creating a factory, this is the atypical way of doing. You don’t want to be returning an instance. Angular will give you an instance in your controller.

     factory('Player', function ($resource) { 
        return $resource('/api/Player/:_id', { });
     })
    

    Here is a service I wrote to interact with a cakephp REST service. I wrote it a while back so just take it as an illustration, I may refactor.

     factory('CommentSvc', function ($resource) {
        return $resource('/cakephp/demo_comments/:action/:id/:page/:limit:format', { id:'@id', 'page' : '@page', 'limit': '@limit' }, {
          'initialize' : { method: 'GET', params: { action : 'initialize', format: '.json' }, isArray : true },
          'save': { method: 'POST', params: { action: 'create', format: '.json' } },
          'query' : { method: 'GET', params: { action : 'read', format: '.json' } , isArray : true },
          'update': { method: 'PUT', params: { action: 'update', format: '.json' } },
        });
    

    }).

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

Sidebar

Related Questions

I'm cross-posting this from the wordpress section, b/c I think the problem lies more
before posting the question i did my research for 10 days so really hope
I am posting this question anew at the behest of the distinguished Mr. John
How do I wordwrap in a spark list w/ an itemrenderer? This posting at
I'm a newbie on Ant so instead of posting this on the official buglist(because
(I've tried posting this on YUI message group but without any luck) Can anyone
Weird behavior and I'm just posting this question to see if anyone knows the
Everytime I submit this form, instead of it POSTing to the server, for some
I'm posting this question not because I am getting some errors but because I
I am designing a creation wizard in ASP.NET MVC 1 and instead of posting

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.