Я пишу свое первое приложение на NativeScript, и я не слишком знаком с интерфейсной разработкой.Я только начал, и создал простой первый экран с двумя кнопками.При нажатии на кнопку следует перейти на другой экран.Я добавил маршрут на основе базового учебника, но теперь приложение просто ничего не показывает.Я не уверен, как я могу отладить проблему или увидеть любой журнал / ошибку, которая может помочь мне выяснить, где проблема.Вот мой код:
app.routing.module.ts
import { NgModule } from "@angular/core";
import { Routes } from "@angular/router";
import { NativeScriptRouterModule } from "nativescript-angular/router";
const routes: Routes = [
{ path: "", redirectTo: "/home", pathMatch: "full" },
{ path: "home", loadChildren: "./home/home.module#HomeModule" },
];
@NgModule({
imports: [NativeScriptRouterModule.forRoot(routes)],
exports: [NativeScriptRouterModule]
})
export class AppRoutingModule { }
home-routing-module.ts
import { NgModule } from "@angular/core";
import { Routes } from "@angular/router";
import { NativeScriptRouterModule } from "nativescript-angular/router";
import { HomeComponent } from "./home.component";
import { MathComponent } from "../math/math.component";
const routes: Routes = [
{ path: "", component: HomeComponent },
{ path: "math", component: MathComponent }
];
@NgModule({
imports: [NativeScriptRouterModule.forChild(routes)],
exports: [NativeScriptRouterModule]
})
export class HomeRoutingModule { }
export const navigatableComponents = [
MathComponent
];
home.component.html
<GridLayout>
<ScrollView class="page">
<StackLayout class="home-panel">
<Label textWrap="true" text="Test" class="h2 description-label"></Label>
<Button text="Math" (tap)="onMathTap()"></Button>
</StackLayout>
</ScrollView>
</GridLayout>
home.component.ts
import { Component, OnInit } from "@angular/core";
import { Router } from "@angular/router";
@Component({
selector: "Home",
moduleId: module.id,
templateUrl: "./home.component.html",
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
onMathTap(): void {
console.log("Math was pressed");
this.router.navigate(["/math"])
}
constructor(private router: Router) { }
ngOnInit(): void {
}
}
app.modules.ts
import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
@NgModule({
bootstrap: [
AppComponent
],
imports: [
NativeScriptModule,
AppRoutingModule
],
declarations: [
AppComponent
],
schemas: [
NO_ERRORS_SCHEMA
]
})
export class AppModule { }