angular 2 unexpected routing on Internet Explorer

久未见 提交于 2019-12-12 04:58:56

问题


My spring-boot/angular 2 app(hosted on embedded tomcat) works fine on Chrome,Safari,Opera and Edge. However on IE the app directly routes to PageNotFound component. Added shims for IE to index.html but still no luck. thank you in advance

index.html

<!doctype html>
<html>

<head>
  <meta charset="utf-8">

  <title> </title>
  <base href=".">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="./res/images/favicon.ico">
  <!-- Latest compiled and minified CSS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
    crossorigin="anonymous">


  <!-- application css -->
  <link href="./res/styles/app.css" rel="stylesheet" />
  <script type="text/javascript" src="https://cdn.ywxi.net/js/1.js" async></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.20/system-polyfills.js"></script>
<script src="https://npmcdn.com/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
</head>

<body>
  <app-root>Uygulama Yükleniyor...</app-root>

</body>


</html>

app-routing.module.ts

rt {NgModule} from '@angular/core';
import {Routes,RouterModule} from '@angular/router';

import {OrtakListComponent} from './ortak/ortak-list.component';
import {LoginComponent} from './login/login.component';
import {PageNotFoundComponent} from './page-not-found.component';
import {AuthGuard} from './guards/auth.guard';
import {ForgotPasswordComponent} from './login/forgot-password.component';
const routes:Routes =[

{path:'' , pathMatch:'full' , redirectTo:'login',},
{path:'ortak/:id', component:OrtakListComponent,canActivate:[AuthGuard],loadChildren:'./ortak/ortak.module#OrtakModule'},
{path:'login' , component:LoginComponent},
{path:'forgotpassword',component:ForgotPasswordComponent},
{path:'**',pathMatch:'full',component:PageNotFoundComponent},

];

@NgModule({
imports:[RouterModule.forRoot(routes)],
exports:[RouterModule]

})

export class AppRoutingModule{}

export const routableComponents = [


    LoginComponent,
    PageNotFoundComponent,
    ForgotPasswordComponent,

];

回答1:


Which version of IE are you using. It will not work unless your browser supports History pushState.



来源:https://stackoverflow.com/questions/44591225/angular-2-unexpected-routing-on-internet-explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!