angularextendssuperangular2-components

How to invoke method from one component to another component in Angular 2?


I have two different component - one component has click event method for the list users & I want to inherit(invoke) that click event method on detail page(another component) )

How to do that, Please help me...

ANSWER UPDATE

Thanks For your Answers.

I have got the solution by Using extend Class & using super() in constructor.

First Class

export class TeamsView {
   constructor(private test:TestService){
   }
   ...
}

Second Class

export class TeamsForm extends TeamsView {
   constructor(private test:TestService, private router: Router){
     super(test)
   }
   ...
}

Solution

  • I have got the solution by Using extend Class & using super() in the constructor.

    First Class

    export class TeamsView {
        constructor(private test:TestService){
        }
        ...
     }
    

    Second Class

    export class TeamsForm extends TeamsView {
        constructor(private test:TestService, private router: Router){
          super(test)
        }
        ...
    }
    

    I don't know its real method for call the class in the constructor for resolving this but I have found this from one of the Angular sites, and its working for me as well.