angular2-chapter01

Get Started

Check code at: https://github.com/wghglory/angular2-fundamental

This article will list systemJS, tsconfig, package.json. Then tell how we can create first component, module and bootstrap module.

Systemjs

(function (global) {
  System.config({
    paths: {
      'npm:': 'node_modules/'        // paths serve as alias
    },
    // map tells the System loader where to look for things
    map: {
      app: 'app',        // our app is within the app folder
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',        // angular bundles
        ...
      'rxjs': 'npm:rxjs',      // other libraries
    },
    // 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'
      }
    }
  });
})(this);

Component

import { Component } from '@angular/core'

@Component({
    template: '<h2>hello world</h2>',
    selector: 'events-app'
})
export class EventsAppComponent {

}

Module

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

import { EventsAppComponent } from './events-app.component'

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

}

bootstrap main.ts

import { platformBrowserDynamic }  from '@angular/platform-browser-dynamic'
import { AppModule } from './app.module'

platformBrowserDynamic().bootstrapModule(AppModule)
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Routing and Navigation Check code at: https://github.com/...
    wghglory閱讀 421評論 0 0
  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,551評論 19 139
  • 孩子和我今天的一次深談,讓我明白孩子可能真的長大了,變的能體貼,關(guān)心別人,慢慢的會用心去感悟身邊的人和事了,居然讓...
    光尚平閱讀 462評論 1 0
  • 古人云:人之將死,其言也善。人之將裸辭,其言也動人。既然都要離開公司了,對公司的感情怎能不好好表達一番呢?抓住這個...
    極浦閱讀 6,187評論 2 2
  • 近來天氣太熱,上班也是沒有激情,覺得就是想睡覺的,所有的行業(yè)都充斥著天熱上班不容易的氣氛,人覺得很沒精神。之前的一...
    心靈的花園閱讀 246評論 0 0

友情鏈接更多精彩內(nèi)容