地址栏不会更新Angular 2中的路径更改

时间:2016-06-28 01:35:54

标签: node.js angular angular2-routing

我希望地址栏中的网址会在我浏览网站时更改。现在,app文件夹位于根文件夹中,app文件夹中包含{components,controllers,models,public,routes,services,views}文件夹。当我点击app上的链接时,网址不会更新。我正在使用具有非冲突API路由的Node后端。有什么帮助吗?

package.json依赖项:

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

路线:

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)];

1 个答案:

答案 0 :(得分:0)

固定。我将所有内容从2.0.0-rc.1改为2.0.0-rc.3,一切都很顺利。

相关问题