perpetuum mobile
29. 11. 2014. dev tool

restmod

  .config(function (restmodProvider, SERVER_BASE_URL) {
    restmodProvider.rebase({
      $config: {
        urlPrefix: SERVER_BASE_URL
      }
    }, 'setHeaders', 'DefaultPacker', 'AMSApi', 'DirtyModel');
  })

  .factory('setHeaders', function (restmod, authentication) {
    var headers;
    if (authentication.isAuthenticated()) {
      var currentUser = authentication.currentUser;
      headers = {
        'Content-Type': 'application/json',
        'Accept': 'application/json',
        'X-User-Email': currentUser.email,
        'X-User-Token': currentUser.authToken
      };
    } else {
      headers = {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
      };
    }

    return restmod.mixin({
      $hooks: {
        'before-request': function (_req) {
          _req.headers = headers;
        }
      }
    });
  })

angular.module('resources.users', [])

  .factory('Users', function (restmod) {
    return restmod.model('/users');
  });

angular.module('species', []).factory('Species', function (restmod) {
  return restmod.model('/species');
});

          users: function (Users) {
            return Users.$collection().$fetch().$asPromise().then(function (users) {
              return users;
            });
          }

        users.$refresh(attrs).$asPromise().then(function (sp) {
          that.tableParams.meta = sp.$metadata.users;
        });