title: In Angular2, use inheritance or inject dependency?
body: <p>In angular2, suppose I have a <code>Parent</code> class and a <code>Child1</code> class, they have the same properties/members and methods. How to initialize the <code>Child1</code> class?</p>
  
  <p>Service    </p>
  
  <pre><code>@Injectable()
  export class Parent {  
      constructor(
          private currentImg: string,
          private catImg: string,
          private dogImg: string,
          private enable: boolean) {
      }
  
      onMouseOver() {
          enable = true;
          currentImg = catImg;
      }
  
      onMouseClick() {
          enable = false;
          currentImg = dogImg;
      }
  
  }
  </code></pre>
  
  <p>One of the child class want to extends <code>Parent</code> class:</p>
  
  <pre><code>import {Parent} from "./Parent";
  
  @Component({
      selector: 'app',
      templateUrl: 'app/child.html',
      providers: [Parent]
  })
  
  export class Child1 {
  
       private currentImg: string = "img/dog.png",
       private catImg: string = "img/cat.png",
       private dogImg: string = "img/dog.png",
       private enable: false
  
      constructor(private _parent: Parent) {
      }
  
      onMouseOver() {
          this._parent.onMouseOver();
      }
  
      onMouseClick() {
          this._parent.onMouseClick();
      }
  }
  </code></pre>