I'm currently working on an application that utilizes the following technologies. In my Typescript file named "test.page.ts", there is a variable called "response: any" that I need to reuse in another Typescript file named "test2.page.html" by calling it as {{response.name}}. Can anyone guide me on how to accomplish this? Thank you.
Technologies I am using:
Ionic 4.10.2
Angular 6
8.1.2 (<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="85e6eaf7e1eaf3e4a8e9ece7c5bdabb4abb4">[email protected]</a>)
TypeScript
Visual Studio Code
test.page.ts
import { Component, OnInit } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { LoadingController, NavController, MenuController } from '@ionic/angular';
@Component({
selector: 'app-test',
templateUrl: './test.page.html',
styleUrls: ['./test.page.scss'],
})
export class TestPage implements OnInit {
response: any;
searchTerm: any = '';
constructor(private http: HttpClient, private loadingCtrl: LoadingController, private navCtrl: NavController) {
this.getData();
}
ngOnInit() {
}
getData() {
this.http.get('URL')
.subscribe((response) => {
this.response = response;
console.log(this.response);
});
}
}