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)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Routing and Navigation Check code at: https://github.com/...
    wghglory阅读 2,920评论 0 0
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,282评论 19 139
  • 孩子和我今天的一次深谈,让我明白孩子可能真的长大了,变的能体贴,关心别人,慢慢的会用心去感悟身边的人和事了,居然让...
    光尚平阅读 3,146评论 1 0
  • 古人云:人之将死,其言也善。人之将裸辞,其言也动人。既然都要离开公司了,对公司的感情怎能不好好表达一番呢?抓住这个...
    极浦阅读 11,277评论 2 2
  • 近来天气太热,上班也是没有激情,觉得就是想睡觉的,所有的行业都充斥着天热上班不容易的气氛,人觉得很没精神。之前的一...
    心灵的花园阅读 1,612评论 0 0

友情链接更多精彩内容