2016-08-31 81 views
0

我有webpack prod構建的問題,組件未加載。沒有錯誤。但其怪異的是開發建設工作正常..組件不加載角2 rc5

下面是代碼快照

貨運list.component.ts

@Component({ 
    selector: 'freightList', 
    template: require('./freight-list.component.html') 
}) 

貨運list.component.html使用文件 - 上傳這是沒有得到加載。

貨運list.component.html

<div [collapse]="hideFileUpload" class="card card-block card-header"> 
     <div class="panel panel-default"> 
     <div class="panel-body"> 
      <file-upload> </file-upload> 
     </div> 
     </div> 
    </div> 
    <br> 
    <div class="panel panel-default"> 
     <div class="panel-heading" style="height:800px; overflow-y: scroll;"> 
     <div class="panel-body"> 
      <table class="table table-bordered table-striped table-hover table-condensed"> 
       <thead> 
        <tr> 
        <th>Section </th> 
        <th>Category</th> 
        <th>Product</th> 
        <th>Markup %</th> 
        <th>Effective Date</th> 
        </tr> 
       </thead> 
............ 
............ 
............ 

下面是文件上傳指令

貨運fileupload.component.ts

import { Component } from '@angular/core'; 
import { FileUploader } from 'ng2-file-upload/ng2-file-upload'; 

const URL = 'app/freight/upload'; 

@Component({ 
    selector: 'file-upload', 
    template: require('./freight-fileupload.component.html') 
}) 

export class FreightFileUploadComponent { 
... 
} 

應用程序代碼。 module.ts

@NgModule({ 
    imports: [ 
    BrowserModule, 
    FormsModule, 
    ReactiveFormsModule, 
    routing, 
    HttpModule 
    ], 
    declarations: [ 
    ErrorComponent, 
    FreightFileUploadComponent, 
    FILE_UPLOAD_DIRECTIVES, 
    CollapseDirective, 
    FreightListComponent, 
    FreightInputComponent, 
    FreightPipe, 
    TYPEAHEAD_DIRECTIVES, 
    AppComponent 
    ], 
    exports:[FreightFileUploadComponent], 
    providers: [ 
    FreightService, 
    ProductMasterSearchService 
    ], 
    bootstrap: [ AppComponent ] 
}) 
export class AppModule { 

} 

任何人都可以幫忙,這裏有什麼不對嗎?

+0

如果它工作在開發環境得到了固定,機會是很高,這不是你的應用程序代碼的問題。這可能是您的構建問題。 – poke

+0

任何提示什麼檢查生產構建? –

+0

不知道,很大程度上取決於你如何建立你的東西。如果真的沒有錯誤(構建時間或運行時間),我會檢查構建輸出是否實際包含了較新的代碼(也許是舊代碼)。 – poke

回答

0

我覺得你的@Component裝飾應該是這樣的: ''

@Component({ 
    selector: 'freightList', 
    templateUrl: 'some_folder/freight-list.component.html' 
}) 

通知templateUrl代替模板 和 'some_folder',而不是

+0

您好Darko,freight-list.component.html被正確加載,其指令不起作用 –

+0

我現在看到了......您是否嘗試將FILE_UPLOAD_DIRECTIVES從「聲明」部分移動到「導入」部分?我不知道.... –

0

這是錯誤的角度RC5,當我upgrated到RC6