title: How can I use Angular 1.5 service
body: <p>I have this service</p>
  <pre><code>class NgCartItem {
  constructor($reactive,  $log) {
      'ngInject';
      this.$log = $log;
  };
  
  item (id, name, price, quantity, data) {
      this.setId(id);
      this.setName(name);
      this.setPrice(price);
      this.setQuantity(quantity);
      this.setData(data);
      // how to return here real object not toObject function????
      // to work properly with inCart.setQuantity(quantity, false);
      return this.toObject();
  
  };
  
  
  setId(id) {
      if (id) this._id = id;
      else {
          this.$log.error('An ID must be provided');
      }
  };
  
  getId() {
      return this._id;
  };
  setQuantity(quantity, relative) {
      var quantityInt = parseInt(quantity);
      if (quantityInt % 1 === 0) {
          if (relative === true) {
              this._quantity += quantityInt;
          } else {
              this._quantity = quantityInt;
          }
          if (this._quantity &lt; 1) this._quantity = 1;
  
      } else {
          this._quantity = 1;
          this.$log.info('Quantity must be an integer and was defaulted to 1');
      }
  };
  
  getQuantity() {
      return this._quantity;
  };
  
  toObject() {
      return {
          id: this.getId(),
          name: this.getName(),
          price: this.getPrice(),
          quantity: this.getQuantity(),
          data: this.getData(),
          total: this.getTotal()
      }
  };
  
  }
  
  const name = 'NgCartItem';
  
  // create a module
  export default angular.module(name, [
      angularMeteor
  ]).service(name, NgCartItem);
  </code></pre>
  <p>And use it in this way</p>
  <pre><code>import { name as NgCartItem } from './ngCartItem';
  import { name as storeService } from './store';
  
  class NgCart {
  
  constructor($reactive, $window, storeService, NgCartItem) {
      'ngInject';
      store = storeService;
      this.NgCartItem = NgCartItem;
  }   
  
  addItem(id, name, price, quantity, data) {
  
      var inCart = this.getItemById(id);
  
      if (typeof inCart === 'object') {
          //Update quantity of an item if it's already in the cart
          inCart.setQuantity(quantity, false);
      } else {
          // here how I created it
          var newItem = this.NgCartItem.item(id, name, price, quantity, data);
          this.$cart.items.push(newItem);
      }
  };
  }
  
  const name = 'NgCart';
  
  // create a module
  export default angular.module(name, [
      angularMeteor,
      storeService,
      NgCartItem
  ]).service(name, NgCart);
  </code></pre>
  <p>And here how I accessing in html</p>
  <pre><code>&lt;tr ng-repeat=&quot;item in ngCartCart.ngCart.getCart().items track by $index&quot;&gt;
                  &lt;td&gt;&lt;span ng-click=&quot;ngCartCart.ngCart.removeItemById(item.getId())&quot; class=&quot;glyphicon glyphicon-remove&quot;&gt;&lt;/span&gt;&lt;/td&gt;
  
                  &lt;td&gt;{{ item.name }}&lt;/td&gt;
                  &lt;td&gt;&lt;span class=&quot;glyphicon glyphicon-minus&quot; ng-class=&quot;{'disabled':item.getQuantity()==1}&quot; ng-click=&quot;item.setQuantity(-1, true)&quot;&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;
                      {{ item.getQuantity() | number }}&amp;nbsp;&amp;nbsp;
                      &lt;span class=&quot;glyphicon glyphicon-plus&quot; ng-click=&quot;item.setQuantity(1, true)&quot;&gt;&lt;/span&gt;&lt;/td&gt;
                  &lt;td&gt;{{ item.price | currency}}&lt;/td&gt;
                  &lt;td&gt;{{ item.total | currency }}&lt;/td&gt;
   &lt;/tr&gt;
  </code></pre>
  <h2>Now the problem.</h2>
  <p>I could get access to <code>item.name</code>,<code>item.price</code>,<code>item.total</code>, but couldn't to <code>item.getQuantity()</code> or <code>item.setQuantity(-1, true)</code>.
  I think that because of my misuse of <code>toObject()</code> function. How to use service properly?
  Here source of <a href="https://github.com/snapjay/ngCart/blob/master/src/ngCart.js" rel="nofollow noreferrer">1.3 version</a>, I rewriting it to 1.5 in ES2015 style</p>