title: AngularJS Inheritance between services
body: <p>I'm quite new to the angular world and have gotten into a problem where I want to implement a Interface(isch) behavior.</p>
  
  <p>I have a "core" factory which is part of my domain and it looks like the following:</p>
  
  <pre><code>(function() {
      'use strict';
  
      var domainModel = angular.module('my.model');
      domainModel.factory('IVehicle', function(Timezone) {
          function IVehicle(DTO) {
              this.Timezone = new Timezone();
              this.DTO = DTO;
              this.engine = DTO.engine;
              this.descriptor = this.getDescriptor();
          }
  
          IVehcile.prototype.getDescriptor = function() {
              if (this.type === -1) {
                  return "this is a diesel vehicle";
              }
              else if (this.type === 0) {
                  return "this is a fuel vehicle";
              }
              else {
                  return "this is a environment vehicle";
              }
          };
  
          IVehicle.prototype.isGenericActivity = function() {
              return true;
          };
  
          return IVehicle;
      });
  })();
  </code></pre>
  
  <p>Now I have a child module which "inherits" this factory:</p>
  
  <pre><code>(function() {
      "use strict";
  
  var models = angular.module('my.model');
  
  models.factory('Car', function(Timezone, IVehicle) {
      function Car(CarDTO) {
          var me = this;
  
  
  
          IVehicle.call(me, CarDTO);
  
          this.additionalAttribute = CarDTO.additionalAttribute
  
          Car.prototype.hasParameters = function() {
          return this.parameters !== undefined &amp;&amp; this.parameters.length !== 0;
      };
  
          Car.prototype = Object.create(ICar.prototype);
  
          Car.prototype.getDescriptor = function() {
          if (this.type === -1) {
              return "this is a diesel car";
          }
          else if (this.type === 0) {
              return "this is a fuel car";
          }
          else {
              return "this is a environment car";
          }
          };
  
          Car.prototype.isGenericActivity = function() {
              return true;
          };
  }
      return Car;
      });
  })();
  </code></pre>
  
  <p>When I run this I get an error on this.descriptor = this.getDescriptor() in IVehicle, as Car does not know about this.getDescriptor(). The fields (this.DTO, this.engine are set in the right way)</p>
  
  <p>Is this the right way to go or is there anyway I can write the IVehicle as a real interface (as a contract on what to be implemented by it's child)? If this is the correct way, how do I handle function calls within the constructor of IVehicle? </p>