Angular2 error- zone.js:1382 GET http:// localhost / traceur 404错误:(SystemJS)XHR错误(404 Not Found)loading http:// localhost:/ traceur

时间:2016-12-22 15:33:17

标签: angular routing

我正在学习Angular2路由。我在app.module.ts中导入了RouterModule,并立即收到此错误。我尝试通过以下在线帮助来解决问题。我不是因为AngularRouting与.NET路由冲突。有人可以帮忙吗?

enter image description here

import { NgModule } from '@angular/core';
import { enableProdMode } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule } from '@angular/http';
import { FormsModule } from '@angular/forms';
import { RouterModule } from "@angular/router";

import { AppComponent } from './app.component';
import { MapComponent } from './map/map.component';
import { VehicleComponent } from './vehicle/vehicle.component';
import { StarComponent } from './Shared/star.component';

enableProdMode();

@NgModule({
    imports: [BrowserModule, HttpModule, FormsModule, RouterModule.forRoot([
        { path: 'vehicledetails', component: VehicleComponent },
        { path: '', redirectTo: 'vehicleDetails', pathMatch: 'full' },
        {path: '**', redirectTo: 'vehicleDetails', pathMatch: 'full' }
    ])],
    declarations: [VehicleComponent, MapComponent, AppComponent, StarComponent],
    bootstrap: [MapComponent]
})

export class AppModule { }

systemjs.config.js:

/**
 * System configuration for Angular 2 samples
 * Adjust as necessary for your application needs.
 */
(function(global) {

  // map tells the System loader where to look for things
  var map = {
    'app':                        '/app', // 'dist',

    '@angular':                   '/node_modules/@angular',
    'angular2-in-memory-web-api': '/node_modules/angular2-in-memory-web-api',
    'rxjs':                       '/node_modules/rxjs'
  };

  // packages tells the System loader how to load when no filename and/or no extension
  var packages = {
    'app':                        { main: 'main.js',  defaultExtension: 'ts' },
    'rxjs':                       { defaultExtension: 'ts' },
    'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'ts' },
  };

  var ngPackageNames = [
    'common',
    'compiler',
    'core',
    'forms',
    'http',
    'platform-browser',
    'platform-browser-dynamic',
    'router',
    'router-deprecated',
    'upgrade',
  ];

  // Individual files (~300 requests):
  function packIndex(pkgName) {
    packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
  }

  // Bundled (~40 requests):
  function packUmd(pkgName) {
    packages['@angular/'+pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
  }

  // Most environments should use UMD; some (Karma) need the individual index files
  var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;

  // Add package entries for angular packages
  ngPackageNames.forEach(setPackageConfig);

  // No umd for router yet
  packages['@angular/router'] = { main: 'index.js', defaultExtension: 'js' };

  var config = {
    map: map,
    packages: packages
  };

  System.config(config);

})(this);

0 个答案:

没有答案