Jestem nowy w maszynopisie i Angular 2. Próbowałem szukać odpowiedzi w sieci, ale wygląda na to, że nie działają one dla mnie.Jak uzyskać dostęp do metody z app.component z innego komponentu?
że mam app.component jak pokazano poniżej:
export class AppComponent implements OnInit {
constructor(public _testService: TestService) { }
listForCart = this._testService.getListForCart();
cartCount = this.listForCart.length;
cartPayableAmount = 0;
ngOnInit() {
this.computeTotal();
}
TestingFunction(){
console.log("Got here");
}
}
Teraz chcę otworzyć TestingFunction w moim app.component w drugiej klasie, jak pokazano poniżej:
export class BuyTestComponent {
constructor(private _testService: TestService) {
}
public pageTitle: string = "ALL PRACTICE TEST SERIES";
TestHere() {
// should call TestingFunction() here.....
}
}
Jak to zrobić? Proszę o pomoc