2016-11-25 4 views
0



저는 Angular 2를 처음 사용하고 첫 번째 응용 프로그램을 만들려고합니다. 나는 첫 번째 응용 프로그램을 개발하는 this 자습서를 따르고 있습니다. 제안 나는 응용 프로그램을 만들어 내 주요 파일은 다음과 같습니다Angular2가 루트 폴더로 리디렉션됩니다.

(function (global) { 
 
    System.config({ 
 
    paths: { 
 
     // paths serve as alias 
 
     'npm:': 'node_modules/' 
 
    }, 
 
    // map tells the System loader where to look for things 
 
    map: { 
 
     // our app is within the app folder 
 
     app: 'app', 
 

 
     // angular bundles 
 
     '@angular/core': 'npm:@angular/core/bundles/core.umd.js', 
 
     '@angular/common': 'npm:@angular/common/bundles/common.umd.js', 
 
     '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js', 
 
     '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js', 
 
     '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js', 
 
     '@angular/http': 'npm:@angular/http/bundles/http.umd.js', 
 
     '@angular/router': 'npm:@angular/router/bundles/router.umd.js', 
 
     '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js', 
 

 
     // other libraries 
 
     'rxjs':      'npm:rxjs', 
 
     'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api', 
 
    }, 
 
    // packages tells the System loader how to load when no filename and/or no extension 
 
    packages: { 
 
     app: { 
 
     main: './main.ts', 
 
     defaultExtension: 'ts' 
 
     }, 
 
     rxjs: { 
 
     defaultExtension: 'js' 
 
     }, 
 
     'angular2-in-memory-web-api': { 
 
     main: './index.js', 
 
     defaultExtension: 'js' 
 
     } 
 
    } 
 
    }); 
 
})(this);


main.ts

systemjs.config.js

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 
 

 
import { AppModule } from './app.module'; 
 

 
platformBrowserDynamic().bootstrapModule(AppModule);


app.module.ts

import { NgModule }  from '@angular/core'; 
 
import { BrowserModule } from '@angular/platform-browser'; 
 

 
import { AppComponent } from './app.component'; 
 

 
@NgModule({ 
 
    imports: [ BrowserModule ], 
 
    declarations: [ AppComponent ], 
 
    bootstrap: [ AppComponent ] 
 
}) 
 
export class AppModule { }


app.component.ts

import { Component } from '@angular/core'; 
 

 
@Component({ 
 
    selector: 'my-app', 
 
    template: '<h1>My First Angular 2 App</h1>' 
 
}) 
 
export class AppComponent { }


그리고 index.html을

<script src="node_modules/core-js/client/shim.min.js"></script> 
 

 
    <script src="node_modules/zone.js/dist/zone.js"></script> 
 
    <script src="node_modules/reflect-metadata/Reflect.js"></script> 
 
    <script src="node_modules/systemjs/dist/system.src.js"></script> 
 

 
    <script src="systemjs.config.js"></script> 
 
    
 
    <script> 
 
     // import the 'app' module to boostrap the application 
 
     System.import('app') 
 
      .catch(function(err){ console.error(err); }); 
 
    </script>


내 프로젝트 폴더의 이름은 myangular입니다

을 다음 코드에서 각 초기화하고 있습니다. 그래서, 내 요청하면 이미지 아래에서 볼 수 있듯이 http://localhost/myangular/index.html

문제

이며, 세 번째 요청은 로컬 호스트 (아파치 서버)의 루트로 이동. 여기 아파치의 기본 페이지 대시 보드. 이 오류가 발생합니다.

enter image description here


내가 구성을 놓치고 곳 제발 도와주세요.
미리 감사드립니다.

+1

이것은 서버 문제 일 가능성이 높으므로 태그를 추가하면 도움이 될 것입니다. – toskv

+0

'idnex.html'의''에 첫 번째 자식으로''를 추가하십시오. –

답변

0

동일한 문제가 발생하여 <base href="/"><base href="/myangular/"> (index.html)으로 변경하여 수정했습니다. 필자의 경우 폴더 이름 뒤에 "/"를 두어야합니다.

관련 문제