2016-08-24 6 views
0

저는 앱을 개발하려고합니다. (RC5) 경로 (지연로드)의 도움으로. 나는 URL에 직접 링크를 넣으려고 했는데도 어떤 경로를 북마크 할 수 없다는 것을 알았지 만 작동하지 않았다. 문제를 봤지만 검색 할 수 없었다 !! 여기 각도 2의 북마크 가능한 경로

내 코어의 일부 조각입니다

index.html을

<html> 
    <head> 
    <title>Angular 2 QuickStart</title> 
    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 

    <!-- 1. Load libraries --> 
    <!-- Polyfill(s) for older browsers --> 
    <script src="node_modules/core-js/client/shim.min.js"></script> 
    <script src="node_modules/zone.js/dist/zone.js"></script> 
    <script src="node_modules/reflect-metadata/Reflect.js"></script> 
    <script src="node_modules/systemjs/dist/system.src.js"></script> 
    <script src="node_modules/ng2-bootstrap/bundles/ng2-bootstrap.min.js"></script> 
    <!-- 2. Configure SystemJS --> 
    <script src="systemjs.config.js"></script> 
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
    <script> 
     System.import('app').catch(function(err){ console.error(err); }); 
    </script> 
    <link rel="stylesheet" href="node_modules/dragula/dist/dragula.css"> 
    <base href = ''> 
    </head> 
    <!-- 3. Display the application --> 
    <body> 
    <main-app class='container'>Loading...</main-app> 
    </body> 
</html> 

AppComponent

import { Component } from '@angular/core'; 

@Component({ 
    selector: 'main-app', 
    template: ` 
     <h4>Today: {{ todaysDate | date:"dd/MM/yy"}}</h4> 
     <nav> 
      <a routerLink = '/home' routerLinkActive = 'active'>Home Tab</a> 
      <a routerLink = '/clients' routerLinkActive = 'active'>Clients Tab</a> 
      <a routerLink = '/aboutus' routerLinkActive = 'active'>About Us Tab</a> 
     </nav> 
     <router-outlet></router-outlet> 
    ` 
}) 
export class AppComponent{ 
    .... 
    .... 
} 

AppRouter :

내가 URL에 링크 직접이을 넣어 시도
import { Routes, RouterModule } from '@angular/router'; 
import { homeComponent } from '../home.component/home.component'; 
import { clientsComponent } from '../clients.component/clients.component'; 
import { aboutusComponent } from '../aboutus.component/aboutus.component'; 

const routes = [ 
    { 
     path: 'home', 
     component: homeComponent 
    }, 
    { 
     path: 'clients', 
     component: clientsComponent 
    }, 
    { 
     path: 'aboutus', 
     component: aboutusComponent 
    }, 
    { 
     path: '**', 
     component: homeComponent 
    } 
]; 
export const appRouteProviders = []; 
export const appRoutes = RouterModule.forRoot(routes); 

는 말 - http://localhost:3000/clients 또는 http://localhost:3000/aboutus, 그것은 작동하지 않습니다! 그렇다면이 링크를 북마크 할 수없는 이유는 무엇입니까? What 게으름로드 정확히 그렇습니까? 제발 도와주세요.

+1

는 http://stackoverflow.com/questions/31415052/angular-2-0-router-not-working-의 DUP 것 같은데 on-reloading-the-browser –

답변

2

이 라인은 당신의 index.html을에 정의가 있는가

<base href='/' > 
+0

예, 정상적으로 작동하지만 특정 URL로 직접 이동할 수 없습니다. !! – Shree

+0

질문을 업데이트하고 index.html 코드를 추가 할 수 있습니까? 이 문제를 해결해야합니다. – 12seconds

+0

예 질문을 업데이트했습니다. – Shree