Angular 2.0 Router Navigation not working on iOS WKWebView

Due to some performance issues, I am trying to update the angularJS2 / phonegap application to use WKWebView on iOS.

Unfortunately, any route navigation calls do not work. This includes calls to routerlink and this.route.navigate . Errors do not occur. Has anyone else seen this and / or perhaps a workaround?

The code works fine using a regular UIWebView.

I am a relative newbie to Angular, so any suggestions are welcome.

Here is the code that looks like this:

 import { Component } from "@angular/core"; import { Routes, Router, ActivatedRoute } from "@angular/router"; import { LoggedInCallback } from "./service/cognito.service"; export class HomeComponent implements LoggedInCallback { constructor(public router:Router){ } isLoggedIn(message:string, isLoggedIn:boolean) { if (isLoggedIn){ this.router.navigate(['/home/cl']); } else { console.log('HomeComponent: '+message); } } 

routing module:

 import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; import { Routes, RouterModule } from '@angular/router'; import { CategoryListComponent } from './categorylist/categorylist.component'; const approutes: Routes = [ { path: 'home/cl', component: CategoryListComponent }, ... ]; @NgModule({ declarations: [ ], imports: [RouterModule.forRoot(approutes), BrowserModule, FormsModule], exports: [RouterModule] }) export class AppRoutingModule { } 

In response to the comment below:

As already mentioned, this is a phonegap application, so most links use (I guess) a file: protocol. However, the first page loads fine, and it links to content within the same JavaScript file. The strange thing is that all the other links associated with the router are also in the same JavaScript file.

I was hoping that someone would understand the nuts and bolts of the router's behavior to explain why it does not work in this environment.

+7
angularjs angular cordova wkwebview angular-ui-router
source share
1 answer

Do you access this through a web server or file: // protocol? Wkwebview seems to have problems with this.

See article

+1
source share

All Articles