jakubrohleder / angular-jsonapi

Simple and lightweight, yet powerful ORM for your frontend that seamlessly integrates with your JsonAPI server.
http://jakubrohleder.github.io/angular-jsonapi/
GNU General Public License v3.0
95 stars 34 forks source link

Reg type of the schema object - singular vs plural #28

Open mkalpana opened 8 years ago

mkalpana commented 8 years ago

In the docs it is mentioned that the type of the schema object must be plural.

Type of an object must be the same as the one in the JSON API response. Should be in plural.

Is this a hard requirement? I have an endpoint in plural say /articles but the type is in singular form article. The schema object is as follows:

var articleSchema = {
  type: 'article',
  id: 'int',
  attributes: {
    title: {presence: true},
    content: {presence: true}
  },
  relationships: {}
};

var restSynchro = $jsonapi.sourceRest.create('Rest synchronization', 'http://localhost:3000/api/articles');
var synchronizer = $jsonapi.synchronizerSimple.create([restSynchro]);
$jsonapi.addResource(articleSchema, synchronizer);

The above code throws up this error:

Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.4.8/$rootScope/infdig?p0=10&p1=%5B%5D
    at REGEX_STRING_REGEXP (http://localhost:3001/bower_components/angular/angular.js:68:12)
    at Scope.parent.$get.Scope.$digest (http://localhost:3001/bower_components/angular/angular.js:15934:19)
    at Scope.parent.$get.Scope.$apply (http://localhost:3001/bower_components/angular/angular.js:16160:24)
    at bootstrapApply (http://localhost:3001/bower_components/angular/angular.js:1679:15)
    at Object.invoke (http://localhost:3001/bower_components/angular/angular.js:4523:17)
    at doBootstrap (http://localhost:3001/bower_components/angular/angular.js:1677:14)
    at bootstrap (http://localhost:3001/bower_components/angular/angular.js:1697:12)
    at angularInit (http://localhost:3001/bower_components/angular/angular.js:1591:5)
    at HTMLDocument.<anonymous> (http://localhost:3001/bower_components/angular/angular.js:29013:5)
    at jQuery.Callbacks.fire (http://localhost:3001/bower_components/jquery/dist/jquery.js:3099:30) undefined

Changing the type to plural articles seems to work. What am I missing?