Angular 2 App升级到2.0.0-rc.1后失败

时间:2016-06-16 16:27:03

标签: typescript angular angular2-routing

我尝试将我的项目更新到2.0.0-rc.1但是得到了这个例外,我无法弄清楚为什么......在我运行服务之后,我没有得到任何错误并在我的dist文件夹/ vendor / @ angular / router-deprecated存在.. 我有什么想法吗?

"http://localhost:4200/vendor/@angular/router-deprecated Failed to load resource: the server responded with a status of 404 (Not Found)
zone.js:461 Unhandled Promise rejection: Error: XHR error (404 Not Found) loading http://localhost:4200/vendor/@angular/router-deprecated
        at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:4200/vendor/zone.js/dist/zone.js:769:30)
        at ZoneDelegate.invokeTask (http://localhost:4200/vendor/zone.js/dist/zone.js:356:38)
        at Zone.runTask (http://localhost:4200/vendor/zone.js/dist/zone.js:256:48)
        at XMLHttpRequest.ZoneTask.invoke (http://localhost:4200/vendor/zone.js/dist/zone.js:423:34)
    Error loading http://localhost:4200/vendor/@angular/router-deprecated as "@angular/router-deprecated" from http://localhost:4200/app/account.js ; Zone: <root> ; Task: Promise.then ; Value: Error: Error: XHR error (404 Not Found) loading http://localhost:4200/vendor/@angular/router-deprecated(…)consoleError @ zone.js:461
zone.js:463 Error: Uncaught (in promise): Error: Error: XHR error (404 Not Found) loading http://localhost:4200/vendor/@angular/router-deprecated(…)consoleError @ zone.js:463
http://localhost:4200/vendor/@angular/router-deprecated Failed to load resource: the server responded with a status of 404 (Not Found)
http://localhost:4200/traceur Failed to load resource: the server responded with a status of 404 (Not Found)"

这是我做路由的地方:

import {Component, provide, Optional, Inject, NgZone} from '@angular/core';
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from '@angular/router-deprecated';
/*import {CliRouteConfig} from './route-config';*/


import {BgtPulseRegisterSimple} from './register-simple/register-simple';
import {BgtPulseLogin} from './login/login';

@Component({
  selector: 'account-app',
  providers: [
    ROUTER_PROVIDERS,
    provide('UserService', { useClass: UserService }),
    provide('NotificationService', { useClass: NotificationServiceMock }),
    provide('RoutingService', { useClass: RoutingServiceMock })
  ],
  template: `
    <h2>Account</h2>
    <nav>
      <a [routerLink]="['Login']" class="nav-login">Login</a>
      <a [routerLink]="['RegisterSimple']" class="nav-register-simple">Register Simple</a>

    </nav>
    <hr>
    <div style="margin:20px; border:1px solid #ccc;">
      <router-outlet></router-outlet>
    </div>
  `,
  directives: [ROUTER_DIRECTIVES, RegisterSimple, FormElements],
  pipes: []
})

@RouteConfig([
  { path: '/login', name: 'Login', component: Login },
  { path: '/register-simple', name: 'RegisterSimple', component: RegisterSimple }

])


export class AccountApp {

  private userStore: any;
  private userState: any = null;

  constructor(
    private ngZone: NgZone,
    @Optional() @Inject('UserStore') UserStore: any
  ) {
    let userData = {
      general: {
        userNodeID: 123,
        username: 'Max.m',
        firstname: 'Max',
        lastname: 'Mustermann',
        salutation: 'Mr',
        birthdate: '23.12.1988'
      },
      address: {
        street: 'Musterstraße',
        houseNumber: '4',
        postCode: '4020',
        city: 'Linz',
        countryCode: 'AT'
      },
      contact: {
        phone: '0123456789',
        email: 'max@mustermann.at',
        newsletter: true
      },
      payment: {
        accountHolderName: 'Max Mustermann',
        bic: 'AT65232323',
        iban: 'AT9837272727272'
      },
      culture: {
        currency: 'EUR',
        language: 'de',
        oddFormat: 'Decimal'
      }
    }

    this.userStore = UserStore;

    this.ngZone.runOutsideAngular(() => {
      this.ngZone.run(() => {
        this.userStore.dispatch({ type: 'USER_LOGIN', data: userData });
      });
    });
  }
}

1 个答案:

答案 0 :(得分:1)

我认为不再支持路由器弃用.....

经过一番阅读后,我设法使用&#34; angular-cli&#34;:&#34; 1.0.0-beta.6&#34;

article帮助我弄明白......它与我以前做的完全不同

希望有所帮助