Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$resource instance methods #10692

Open
Open
@ilanbiala

Description

@ilanbiala

It would be nice to develop $resource with some OOP class functionality such as instance methods. Take this code:

angular.module('app', ['ngResource'])
  .factory('PanelUser', ['$resource', function($resource) {
    return $resource('/api/panel/users/:userId', {
      userId: '@_id'
    }, {
      invite: {
        method: 'POST'
      },
      hasAuthorization: {
        url: '/api/panel/auth/:user',
        params: {
          user: '@user'
        },
        method: 'POST'
      }
    });
  }]);

Now say I instantiate a user var user = new PanelUser(); How can I call user.hasAuthorization() to do some checks on the client. I don't need to make requests to the server, but I need to be able to do it on each user as an instance method. It seems like this functionality isn't present, is there some way to make it a part?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions