2017-05-11 2 views
0

나는 angularjs를 처음 사용하고 angular2를 사용하는 데모 응용 프로그램을 개발했습니다. 응용 프로그램을 실행하는 동안 다음 오류가 발생합니다. 아래의 오류 404, 확장명이 .js 브라우저에서 동일한 URL (예 : http://localhost:4679/Binder/CustomerModuleLibrary) 충돌하면 있지만, 스크립트는 브라우저로로드됩니다. CustomerModuleLibrary.ts에 대한오류 : Angular2 응용 프로그램에서 XHR 오류 (404 찾을 수 없음)

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 

코드

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 { } 

코드 또한

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

,할까요 Startup.ts systemjs.config.js 파일에서
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; 
import {CustomerModuleLibrary} from './CustomerModuleLibrary'; 
const platform = platformBrowserDynamic(); 
platform.bootstrapModule(CustomerModuleLibrary); 

에 대한 나는 앱을 실행하기 전에 npm start를 수행한다. lication?

+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 
    });