Skip to content

502 Super Power Model Collection

zarlex edited this page Mar 6, 2017 · 1 revision

SuperPower Model/Collection

For the endpoint super-powers we create a model and a collection to work with the data form the endpoint.

Model

Create the file super-power.model.js in hero/models

angular.module('mwPortal.Main')
  .service('SuperPowerModel', function (MwPortalModel) {
    return MwPortalModel.extend({
      endpoint: '/super-powers'
    });
  });

Collection

Create the file super-powers.colelction.js in hero/collections

angular.module('mwPortal.Main')
  .service('SuperPowersCollection', function (MwPortalCollection, SuperPowerModel) {
    return MwPortalCollection.extend({
      endpoint: '/super-powers',
      model: SuperPowerModel
    });
  });

Include the created files in your index.html

...
<!-- Hero module -->
<script src="app/modules/hero/models/super-power.model.js"></script>
<script src="app/modules/hero/collections/super-powers.collection.js"></script>
...
Clone this wiki locally