javascript - AngularJS Inheritance between services -


i'm quite new angular world , have gotten problem want implement interface(isch) behavior.

i have "core" factory part of domain , looks following:

(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 diesel vehicle";             }             else if (this.type === 0) {                 return "this fuel vehicle";             }             else {                 return "this environment vehicle";             }         };          ivehicle.prototype.isgenericactivity = function() {             return true;         };          return ivehicle;     }); })(); 

now have child module "inherits" factory:

(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 && this.parameters.length !== 0;     };          car.prototype = object.create(icar.prototype);          car.prototype.getdescriptor = function() {         if (this.type === -1) {             return "this diesel car";         }         else if (this.type === 0) {             return "this fuel car";         }         else {             return "this environment car";         }         };          car.prototype.isgenericactivity = function() {             return true;         }; }     return car;     }); })(); 

when run error on this.descriptor = this.getdescriptor() in ivehicle, car not know this.getdescriptor(). fields (this.dto, this.engine set in right way)

is right way go or there anyway can write ivehicle real interface (as contract on implemented it's child)? if correct way, how handle function calls within constructor of ivehicle?


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -