我正在从NativeScript TabView模板应用程序(https://github.com/NativeScript/template-tab-navigation-ng)开始创建应用程序,我无法弄清楚如何以编程方式导航到AppComponent的页面路由器出口内的页面 . 例:
export class AppComponent{
constructor(private router: RouterExtensions, private currentRoute: ActivatedRoute) {
// Use the component constructor to inject providers.
}
getIconSource(icon: string): string {
const iconPrefix = isAndroid ? "res://" : "res://tabIcons/";
return iconPrefix + icon;
}
navigateToPage(): void {
this.router.navigate(['../page'], { relativeTo: this.currentRoute });
}
}
这可以在page-router-outlet内的页面内正常工作,但是当我从AppComponent调用它时,我收到一个控制台错误,例如:
Cannot match any routes. URL Segment: 'page'
我的实际代码在这里:https://github.com/rchisholm/saint_stan
我的实际完整错误来自调试控制台:
Unhandled Promise rejection: Cannot match any routes. URL Segment: 'novena-day/1' ; Zone: <root> ; Task: Promise.then ; Value: Error: Cannot match any routes. URL Segment: 'novena-day/1' Error: Cannot match any routes. URL Segment: 'novena-day/1'
我尝试导航是在AppComponent中的OnInit中的LocalNotifications.addOnMessageReceivedCallback内部 .
这似乎应该很简单 . 我对此有点新意,所以任何帮助都将不胜感激 .
我使用的是最新版本的NativeScript,TypeScript和Angular .
谢谢!
1 回答
这是您导航到某些TabView选项卡的方式 . 您的商店必须在app.routing.ts文件中设置 .