Onclick图像移动另一页不起作用

问题描述:

  • 我是新来的本地脚本。我从Alert页导航到 Naviagation页面。我已发布所有相关代码。请检查它。Onclick图像移动另一页不起作用

  • 我没有收到任何问题。在执行onClick图像时,我可以调用此方法onNotification()

  • 我能够看到这个控制台登录命令提示符

    console.log("SteveCheck", "Test");

  • 但我不知道,为什么它没有移动到通知页面上时,在警报按钮 点击page.Bowow我已添加所有相关的代码。

app.module.ts:

import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; 
import { NativeScriptModule } from "nativescript-angular/nativescript.module"; 
import { AlertComponent } from "./AlertFolder/alert.component"; 


import { NativeScriptRouterModule } from "nativescript-angular/router" 
import {AppRoutes, AppComponents } from "./app.routing"; 

@NgModule({ 
    declarations: [AlertComponent, ...AppComponents], 
    bootstrap: [AlertComponent], 
    imports: [ 
    NativeScriptModule, 
    NativeScriptRouterModule, 
    NativeScriptRouterModule.forRoot(AppRoutes) 
    ], 

    schemas: [NO_ERRORS_SCHEMA], 
}) 

export class AppModule {} 

app.routing.ts:

import { AlertComponent } from "./AlertFolder/alert.component"; 
import { NotificationComponent } from "./Noficiation/notification"; 

export const AppRoutes:any = [ 

    { path: "", component: AlertComponent }, 
    { path: "NotificationPage", component: NotificationComponent} 
]; 

export const AppComponents: any = [ 

AlertComponent, 
NotificationComponent 

]; 

alert.component.ts:

@Component({ 
selector: "sdk-child-component", 
moduleId: module.id, 
.... 
}) 

export class AlertComponent { 

..... 
..... 
public constructor(private router: Router, private routerExtensions: RouterExtensions){ 

this.alertList = []; 
} 


onNotification() { 

    console.log("SteveCheck", "Test"); 
    this.router.navigate(["NotificationPage"]); 

} 

} 

alert.component.html:

<StackLayout class="borders" orientation="horizontal" > 
    <Label class="notification-label" text="Notification Center" ></Label> 
    <Image src="res://right_arrow" stretch="none" class="right-arrow" (tap)="onNotification()"></Image> 

    </StackLayout> 

我必须使用路径文件夹名称的通知。我将第二页NotificationComponent放置在该Notification文件夹中,这就是为什么我无法在页面之间导航的原因。

通过改变这样的:

this.router.navigate(["NotificationPage"]); 

这样:

this.router.navigate(["Notification"]); 

固定我的问题

constructor(private routerExtensions: RouterExtensions) { 
    // ... 
} 
this.routerExtensions.navigate(["/NotificationPage"]); 
+0

我试过这个解决方案,它不工作。 – Steve

+0

我认为有些东西穿过了布线的线索。路线前是否有系统警报? – Habeeb