2017-03-06 36 views
7

我想在角度2應用程序的起點做些事情,但我無法得到這一點。如果有人知道這件事,請幫助我。在調用AppComponent.ts之前,Angular 2的起點是什麼?

在此先感謝。

+3

'Index.html'是開始和它連續的'main.ts',然後它與''一起繼續並繼續。 – Smit

+2

這是如何工作的:https://wildermuth.com/2016/07/31/Is-Angular2-Too-Full-of-Ceremony – Smit

+1

好的謝謝@Smit –

回答

4

Index.html是開始,它連續main.ts然後將其去與<my-app>和推移和

的Index.html後,systemjs.config.js被加載。它告訴哪個文件運行。並在systemjs.config.js,它告訴加載main.ts開始。

包告訴系統如何加載器加載時沒有文件名和/或 沒有擴展名

經過一番研究,看看下面systemjs.config.js文件。評論說明它的作用和時間。

/** 
* System configuration for Angular samples 
* Adjust as necessary for your application needs. 
*/ 
(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', 
     '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js', 
     // other libraries 
     'rxjs':      'npm:rxjs', 
     'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js', 
     //For android Internet 
     'moment': 'npm:moment', 
     'jquery':'npm:jquery/dist/jquery.js', 
     'fullcalendar':'npm:fullcalendar/dist/fullcalendar.js' 
    }, 
    // packages tells the System loader how to load when no filename and/or no extension 
    packages: { 
     app: { 
     main: './main.js', 
     defaultExtension: 'js' 
     }, 
     rxjs: { 
     defaultExtension: 'js' 
     }, 
     moment: { main: './moment.js', defaultExtension: 'js' } 
    } 
    }); 
})(this);