This still WFM:
@Injectable()
export class LinkService {
private link$ = new BehaviorSubject<string>("nowhere");
watchLink(): Observable<string> {
return this.link$;
}
pokeLink(link: string) {
this.link$.next(link);
}
}
export class HomePage {
destination = "";
constructor(private linker: LinkService) {
}
moveRoad(): void {
this.linker.pokeLink(this.destination);
}
}
<ion-content>
<ion-item>
<ion-label>where to go?</ion-label>
<ion-input [(ngModel)]="destination"></ion-input>
</ion-item>
<ion-item button (click)="moveRoad()">move road</ion-item>
</ion-content>
export class AppComponent {
link = "nowhere";
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
private linker: LinkService,
) {
this.initializeApp();
linker.watchLink().subscribe(link => this.link = link);
}
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
}
<ion-app>
<ion-header>
<a [routerLink]="link">road to nowhere</a>
</ion-header>
<ion-content>
<ion-router-outlet></ion-router-outlet>
</ion-content>
</ion-app>