I have a function in app.componts.ts
I want to return value to home.ts
how I can do this in ionic 3
I have tried with events API
and tried this as well
so how i can return variable from app.component.ts
to another home page ts ionic 3
You can define an @Input() in your component and when the event is raised pass the value to the input. Here is the complete example
Create SharedProvider for save global variable over the all app.
sharedProvider.ts
import { Injectable } from '@angular/core';
@Injectable()
export class SharedProvider {
x:string = '';
}
app.component.ts
export class MyApp {
constructor(private sharedProvider:SharedProvider) {
this.sharedProvider.x = 'someValue';
}
}
homePage.ts
export class HomePage {
constructor(private sharedProvider:SharedProvider) {
console.log('x value: ', this.sharedProvider.x);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.