angular 4: call a method from a different component

后端 未结 2 640

I have 2 sibling components, I am doing an http request in one component, and if a particular condition happens, it should make another http request, written in another comp

2条回答
  •  执笔经年
    2020-12-31 20:23

    Create a instance of SendCardComponent in the InputFieldComponent

    import { Http } from '@angular/http';
    import { SendCardComponent } from '../send-card/send-card.component';
    
    export class InputFieldComponent{
    
        //your other variables and methods
    
        constructor(private http : Http) { }
    
        let saro = new SendCardComponent(this.http);
    
        saro.sendCard()
    
    }
    

提交回复
热议问题