您好我是nativescript-angular的新手,试图解决路由器的工作原理。我阅读文档,但因为我使用的是样板文件,我无法理解它是如何工作的...... https://github.com/NativeScript/template-tab-navigation-ng
我只向该项目添加了1个组件,这是一个空的登录组件,我将其设置为根组件。
我想要做的是如何从登录组件切换到标签组件?使用按钮功能
APP-routing.module.js:
import { NgModule } from "@angular/core";
import { Routes } from "@angular/router";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { LoginComponent } from './login/login.component';
const routes: Routes = [
{ path: 'login', component: LoginComponent },
{ path: "", redirectTo: "/tabs", pathMatch: "full" },
{ path: "tabs", loadChildren: "./tabs/tabs.module#TabsModule" }
];
@NgModule({
imports: [NativeScriptRouterModule.forRoot(routes)],
exports: [NativeScriptRouterModule]
})
export class AppRoutingModule { }
app.module.ts:
import { NgModule, NgModuleFactoryLoader, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
import { LoginComponent } from "./login/login.component";
@NgModule({
bootstrap: [
LoginComponent
],
imports: [
NativeScriptModule,
AppRoutingModule,
],
declarations: [
AppComponent,
LoginComponent
],
schemas: [
NO_ERRORS_SCHEMA
]
})
export class AppModule { }
答案 0 :(得分:0)
只需在登录组件
中添加指向组件标签的链接即可this.router.navigate(["/tabs"]);