2017-02-22 6 views
0

Мое приложение отлично работает, когда я запускаю npm. Но при попытке построить с использованием prod-npm run build: prodОшибка при выполнении npm run build: prod моего приложения Angular2

Это метафизическая ошибка в одном из скомпилированных файлов ts. Я не могу понять, почему.

Пожалуйста, помогите

Компонент файл из файла JS.

import {Component, OnInit} from '@angular/core'; 
import {ActivatedRoute, Router} from '@angular/router'; 

import { CompetitionService } from '../shared/competition.service'; 

@Component({ 
    selector:'competitiontable', 
    styleUrls:['table.component.css'], 
    templateUrl:'table.component.html' //or use absoulte path with templateUrl:'app/competition/competition.component.html'require('./table.component.html') 
}) 

export class TableComponent implements OnInit{ 

    constructor(private competitionService:CompetitionService,private route:ActivatedRoute,private router: Router) { 

    } 
     competitionId:string; 
     competitionTeams:any; 
     teamId:string; 
     //groupComptetitionTeams:any; 
     visibleLeague:boolean; 
     visibleTournament:boolean; 

    ngOnInit(){ 
     this.competitionId = this.route.snapshot.params['id']; 
     console.log("competition ID"+this.competitionId); 
     this.getTeams(); 
    } 

    getTeams(){ 
     this.competitionService.getTeams(this.competitionId).subscribe(teams => { 
                   if(teams.standing){ 
                    this.visibleLeague = true; 
                    this.visibleTournament = false; 
                    return this.competitionTeams = teams.standing; 
                   }else{ 
                    this.visibleLeague = false; 
                    this.visibleTournament = true; 
                    return this.competitionTeams = teams.standings; 
                   } 
     }); 
     //this.competitionService.getTeams(this.competitionId).subscribe(teams => (this.groupComptetitionTeams = teams.standings)); 


    } 

    onSubmit(team:any){ 
     this.teamId = team._links.team.href.split('/').pop(-1); 
     this.competitionService.storeTeamCrest(team.crestURI); 
     this.router.navigate(['team', {id: this.teamId}]); 
    } 


} 

Ошибка в файле ts. Coudnt вставить весь JS, как это очень большой

detectChangesInternal(throwOnChange:boolean):void { 
    const valUnwrapper:any = new import13.ValueUnwrapper(); 
    valUnwrapper.reset(); 
    const currVal_4_0_0:any = valUnwrapper.unwrap(import3.castByValue(this._pipe_keys_0_0,(<View_TableComponent0>this.parentView)._pipe_keys_0.transform)(this.parentView.context.competitionTeams)); // this is the error line 
    this._NgFor_4_6.check_ngForOf(currVal_4_0_0,throwOnChange,valUnwrapper.hasWrappedValue); 
    this._NgFor_4_6.ngDoCheck(this,this._anchor_4,throwOnChange); 
    this._vc_4.detectChangesInNestedViews(throwOnChange); 
    } 

Ошибка в консоли при построении

[at-loader] Checking finished with 1 errors 
Error in bail mode: [at-loader] compiled\src\app\table\table.component.ngfactory.ts:530:51 
    TS2346: Supplied parameters do not match any signature of call target. 

Труба

import { PipeTransform, Pipe } from '@angular/core'; 

@Pipe({name: 'keys'}) 
export class KeysPipe implements PipeTransform { 
    transform(value, args:string[]) : any { 
    let keys = []; 
    for (let key in value) { 
     keys.push({key: key, value: value[key]}); 
    } 
    //console.log("Keys"+keys); 
    return keys; 
    } 
} 
+0

const currVal_4_0_0: any = valUnwrapper.unwrap (import3.castByValue (this._pipe_keys_0_0, ( this.parentView) ._ pipe_keys_0.transform) (this.parentView.context.competitionTeams)); // это строка с ошибкой Не могли бы вы разместить трубку, которую вы добавили для этого кода, строка ошибки указана на pipe_keys –

+0

@RahulSingh добавила трубы в код –

ответ

0

Похоже один из ваших услуг ожидает значение быть разобранным, но не получать его, возможно, попробуйте сделать параметр переданным необязательным.

+0

@ tan639 Я тебя не понял. Если это так, то как приложение работает при запуске npm только тогда, когда я пытаюсь его построить, он дает мне эту ошибку. –

+0

Как узнать, что? –

+0

Возможно, это было бы более безопасным подходом 'ngOnInit() { this.competitionId = this.route.snapshot.params ['id']; if (this.competitionId) это.getTeams (this.competitionId); прочее this.getTeams(); } getTeams (comp_id: строка) { .... ' – tan369

Смежные вопросы