How to use one component data in another component in angular 6?

Discussão em 'Angular' iniciado por viki, Setembro 10, 2024.

  1. viki

    viki Guest

    I have a component.ts file which is making a http call & retrieving json data as response. I need to use this response in another component.ts file. Can anyone tell me how to process this? first component.ts:

    @Component({
    selector: 'app-cat',
    templateUrl: './first.component.html',
    styleUrls: ['./first.component.css']
    })
    export class firstComponent extends Lifecycle {
    this.http.get('/name',{responseType:"json"}).subscribe(
    response => {
    console.log("data :"+response);
    console.log("data stringify:"+JSON.stringify(response));

    });
    }


    I need to use the json content which is in the response in my second component file. Can anybody tell me how to proceed this in angular6?

    Continue reading...

Compartilhe esta Página