2017-10-28 16 views
0

プロダクションサーバーへのアップロードおよびアップロード後にこのエラーが発生しました。私はangular4に角度cliを使用しています。このすべては、フィーチャモジュールにルートガードを追加したときに実際に始まりました。私は警備員がいないときに戻ったが、エラーは依然として続きます。ローカルマシンでngを実行すると、このエラーは発生しません。 これは私のアプリモジュールです:Uncaught TypeError:__extends(Subscriber.js:5)で未定義のプロパティ 'prototype'を読み取ることができません。

import { BrowserModule } from '@angular/platform-browser'; 
import { NgModule } from '@angular/core'; 
import { FormsModule } from '@angular/forms'; 
import { HttpModule } from '@angular/http'; 
import { HashLocationStrategy, LocationStrategy } from '@angular/common'; 

import { AppComponent } from './app.component'; 
import { LoginComponent } from './login/login.component'; 
import { RegisterComponent } from './register/register.component'; 

/* Routing Module */ 
import { AppRoutingModule } from './app-routing.module'; 

/* Authentication */ 
import {AuthenticateService} from './authenticate.service'; 
import {AuthGuard} from './auth.guard'; 


import {DashboardModule} from './dashboard/dashboard.module'; 

@NgModule({ 
    declarations: [ 
    AppComponent, 
    LoginComponent, 
    RegisterComponent 
    ], 
    imports: [ 
    BrowserModule, 
    FormsModule, 
    HttpModule, 
    DashboardModule, 
    AppRoutingModule 
    ], 
    providers: [ 
    { provide: LocationStrategy, useClass: HashLocationStrategy}, 
     AuthenticateService, 
     AuthGuard 
     ], 
     bootstrap: [AppComponent] 
    }) 
    export class AppModule { } 

マイ認証サービス:

import { Injectable } from '@angular/core'; 
import {Response, Headers, Http, RequestOptionsArgs} from '@angular/http'; 
import {Observable} from 'rxjs/Observable'; 
import 'rxjs/add/operator/map'; 
import 'rxjs/add/operator/catch'; 

@Injectable() 
export class AuthenticateService { 

    baseUrl = 'myurl/public'; 
    constructor(private http: Http) { } 
    register(form) { 
     return this.http.post(`${this.baseUrl}/register`, form) 
     .map((response: Response) => { 
      const user = response.json(); 
      if (user.status) { 
      // store user details and jwt token in local storage to keep user logged in between page refreshes 
      localStorage.setItem('loggedUser', JSON.stringify(user)); 
      } 
      return user; 
     }) 
     .catch((error: any) => Observable.throw(error.json().error || {message: 'Server Error'})); 
    } 

    login(form): Observable<Response> { 
     const headersObj = new Headers(); 
     headersObj.set('Content-Type', 'application/json'); 

     const requestArg: RequestOptionsArgs = { headers: headersObj, method: 'POST' }; 
     // const telephone = form.telephone; 
     // const password = form.password; 
     return this.http.post(`${this.baseUrl}/login`, form, requestArg) 
     .map((response: Response) => { 
      const user = response.json(); 
      if (user.response.status) { 
      localStorage.setItem('loggedUser', JSON.stringify(user.response)); 
      } 
      return user.response; 
     }) 
     .catch((error: any) => Observable.throw(error.json().error || {message: 'Server Error'})); 
    } 

    logout() { 
    // remove user from local storage to log user out 
    localStorage.removeItem('loggedUser'); 
    } 

} 

マイルートガード:

import { Injectable } from '@angular/core'; 
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; 
// import {AuthenticateService} from './authenticate.service'; 

@Injectable() 
export class AuthGuard implements CanActivate { 
    constructor(private router: Router) { 
    } 

    canActivate(route: ActivatedRouteSnapshot, 
       state: RouterStateSnapshot): boolean { 
    if ((!localStorage.getItem('loggedUser'))) { 
     // not logged in so redirect to login page 
     this.router.navigate(['/login'], { queryParams: { returnUrl: state.url }}); 
     return false; 
    } else { 
     return true; 
    } 
    } 
} 

のAppルーティングモジュール:

import { NgModule } from '@angular/core'; 
import {RouterModule, Routes} from '@angular/router'; 
import {LoginComponent} from './login/login.component'; 
import {RegisterComponent} from './register/register.component'; 


export const routes: Routes = [ 
    {path: '', redirectTo: 'dashboard', pathMatch: 'full'}, 
    {path: 'login', component: LoginComponent}, 
    {path: 'register', component: RegisterComponent}, 
]; 
@NgModule({ 
    imports: [ 
    RouterModule.forRoot(routes) 
    ], 
    exports: [ 
    RouterModule 
    ] 
}) 
export class AppRoutingModule { } 

ガード付きモジュール:

import { NgModule } from '@angular/core'; 
import { CommonModule } from '@angular/common'; 
import { RouterModule } from '@angular/router'; 
import {FormsModule} from '@angular/forms'; 

import { DashboardRoutingModule } from './dashboard-routing.module'; 

import { DashboardComponent } from './dashboard.component'; 
import { DashboardHomeComponent } from './dashboard-home/dashboard-home.component'; 
import { UsersComponent } from './users/users.component'; 
import { TransactionsComponent } from './transactions/transactions.component'; 
import { UsersService } from './services/users.service'; 

@NgModule({ 
    imports: [ 
    CommonModule, 
    FormsModule, 
    RouterModule, 
    DashboardRoutingModule 
    ], 
    exports: [ DashboardComponent ], 
    declarations: [ DashboardComponent, DashboardHomeComponent, UsersComponent, TransactionsComponent], 
    providers: [ UsersService ] 
}) 
export class DashboardModule { } 

機能モジュール部品:

import { NgModule } from '@angular/core'; 
import { RouterModule, Routes } from '@angular/router'; 

import {DashboardComponent} from './dashboard.component'; 
import {DashboardHomeComponent} from './dashboard-home/dashboard-home.component'; 
import {UsersComponent} from './users/users.component'; 
import {TransactionsComponent} from './transactions/transactions.component'; 
import {AuthGuard} from '../auth.guard'; 


export const dashboardRoutes: Routes = [ 
    { 
    path: 'dashboard', 
    component: DashboardComponent, 
    canActivate: [ AuthGuard ], 
    children: [ 
    {path: '', component: DashboardHomeComponent}, 
    {path: 'users', component: UsersComponent}, 
    {path: 'transactions', component: TransactionsComponent} 
    ]} 
    // {path: 'dashboard', component: DashboardComponent} 
]; 
@NgModule({ 
    imports: [ 
    RouterModule.forChild(dashboardRoutes) 
    ], 
    exports: [ 
    RouterModule 
    ], 
    declarations: [] 
}) 
export class DashboardRoutingModule { } 

答えて

0

私はエラーを検出しました、私は私の機能モジュールにしても、私の機能ルーティングモジュールでルータのモジュールをインポートしました。