单击图像移动另一个页面不起作用

Onclick image to move another page is not working

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>
constructor(private routerExtensions: RouterExtensions) {
    // ...
}
this.routerExtensions.navigate(["/NotificationPage"]);

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

通过改变这个:

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

对此:

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

解决了我的问题

这里有一个例子,我们可以在 img 标签上包含 routerLink-

 <img src="../../../assets/images/Notification.png" [routerLink]="['/NotificationPage']" width="55%" height = "200px" class="img-responsive" style="margin-left: 220px">