2017-05-11 12 views
0

私はangularjsを初めて使用し、angular2を使用したデモアプリケーションを開発しました。 アプリケーションの実行中に次のエラーが発生します。私は同じURL(すなわちhttp://localhost:4679/Binder/CustomerModuleLibrary)の拡張子.jsを持つブラウザでヒットした場合、スクリプトはブラウザに読み込まれます。エラー:Angular2アプリケーションのXHRエラー(404 Not Found)

CustomerModuleLibrary.ts systemjs.config.jsファイルで

import {NgModule} from '@angular/core'; 
import {BrowserModule} from '@angular/platform-browser'; 
import {CustomerComponent} from './CustomerComponent'; 
import {FormsModule} from '@angular/forms' 

@NgModule({ 
    imports: [BrowserModule,FormsModule], 
    declarations: [CustomerComponent], 
    bootstrap: [CustomerComponent] 
}) 
export class CustomerModuleLibrary { } 

コードStartup.ts

ため
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; 
import {CustomerModuleLibrary} from './CustomerModuleLibrary'; 
const platform = platformBrowserDynamic(); 
platform.bootstrapModule(CustomerModuleLibrary); 

、また

packages: { 
app: { 
    main: '../../Binder/Startup.js', 
defaultExtension: 'js' 
}, 
rxjs: { 
defaultExtension: 'js' 
}, 

ため

Here is the error: 

Error: Error: XHR error (404 Not Found) loading http://localhost:4679/Binder/CustomerModuleLibrary 
     at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:4679/node_modules/zone.js/dist/zone.js:698:29) 
     at ZoneDelegate.invokeTask (http://localhost:4679/node_modules/zone.js/dist/zone.js:265:35) 
     at Zone.runTask (http://localhost:4679/node_modules/zone.js/dist/zone.js:154:47) 
     at XMLHttpRequest.ZoneTask.invoke (http://localhost:4679/node_modules/zone.js/dist/zone.js:335:33) 
    Error loading http://localhost:4679/Binder/CustomerModuleLibrary as "./CustomerModuleLibrary" from http://localhost:4679/UI/startup/../../Binder/Startup.js 

コード、すべき私はアプリを実行する前にnpmの開始を実行する結婚?

+0

問題は –

+0

AngularProjectは3つのフォルダ1.バインダー1aと、あなたの完全なディレクトリ構造を示し、system.config.js' 'の誤った構成です。 CustomerComponent.ts 1b.CustomerModuleLibrary.ts 1c.Statuup.ts 2.Model 2a.Customer.ts 3.UI 3a。 Customet.html 3b.Master.html 4.System.config.js – Learner

+0

プロジェクト設定でプランナーまたはgithubリポジトリを作成するとお手伝いします –

答えて

0

私はこれをmaster.htmlに追加していませんでした。これを追加すると問題が解決しました。

System.config({ 
     "defaultJSExtensions":true 
    }); 
関連する問題