2016-06-28 6 views
0

Ich möchte die URL in der Adressleiste ändern, wie ich durch meine Website gehe. Derzeit befindet sich der App-Ordner im Stammordner mit den Ordnern {Komponenten, Controller, Modelle, öffentliche Ordner, Routen, Dienste, Ansichten} im App-Ordner. Wenn ich auf einen Link auf der app klicke, wird die URL nicht aktualisiert. Ich verwende ein Knoten-Backend mit nicht in Konflikt stehenden API-Routen. Irgendeine Hilfe?Adressleiste nicht aktualisieren Route ändern in Angular 2

package.json Abhängigkeiten:

"dependencies": { 
    "@angular/common": "2.0.0-rc.1", 
    "@angular/compiler": "2.0.0-rc.1", 
    "@angular/core": "2.0.0-rc.1", 
    "@angular/http": "2.0.0-rc.1", 
    "@angular/platform-browser": "2.0.0-rc.1", 
    "@angular/platform-browser-dynamic": "2.0.0-rc.1", 
    "@angular/router": "^3.0.0-alpha.7", 
    "@angular/router-deprecated": "2.0.0-rc.1", 
    "@angular/upgrade": "2.0.0-rc.1", 
    "angular2": "^2.0.0-beta.17", 
    "angular2-in-memory-web-api": "0.0.11", 
    "bcrypt-nodejs": "latest", 
    "body-parser": "~1.0.0", 
    "bootstrap": "^3.3.6", 
    "connect-flash": "~0.1.1", 
    "cookie-parser": "~1.0.0", 
    "core-js": "^2.4.0", 
    "ejs": "~0.8.5", 
    "express": "~4.0.0", 
    "express-session": "~1.0.0", 
    "method-override": "~1.0.0", 
    "mongoose": "~3.8.1", 
    "morgan": "~1.0.0", 
    "passport": "~0.1.17", 
    "passport-facebook": "~1.0.2", 
    "passport-google-oauth": "~0.1.5", 
    "passport-local": "~0.1.6", 
    "passport-twitter": "~1.0.2", 
    "reflect-metadata": "^0.1.3", 
    "rxjs": "5.0.0-beta.6", 
    "systemjs": "0.19.27", 
    "typescript": "^1.8.10", 
    "typings": "^1.0.4", 
    "zone.js": "^0.6.12" 
} 

index.html:

<!DOCTYPE html> 
<html> 
<head> 
    <base href="/"> 
    <title>Todo List</title> 
    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css"> 
    <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap-theme.min.css"> 
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css"> 
    <style> 
    body  { padding-top:80px; } 
    </style> 

    <!-- 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> 

    <!-- 2. Configure SystemJS --> 
    <script src="systemjs.config.js"></script> 
    <script> 
    System.import('app').catch(function(err){ console.error(err); }); 
    </script> 
</head> 

<!-- 3. Display the application --> 
<body> 
    <my-app>Loading...</my-app> 
</body> 
</html> 

Routen:

import { provideRouter, RouterConfig } from '@angular/router/index'; 
import { IndexComponent } from "../components/index.component"; 
import { ProfileComponent } from "../components/profile.component"; 
import { SignupComponent } from "../components/signup.component"; 

export const appRoutes: RouterConfig = [ 
    { path: '',   component: IndexComponent }, 
    { path: 'profile', component: ProfileComponent }, 
    { path: 'signup', component: SignupComponent } 
]; 

export const APP_ROUTER_PROVIDER = [provideRouter(appRoutes)]; 

Antwort

0

behoben. Ich habe alles von 2.0.0-rc.1 auf 2.0.0-rc.3 geändert und alles ist gut.

Verwandte Themen