美文网首页
angular2-chapter01

angular2-chapter01

作者: wghglory | 来源:发表于2017-04-23 23:44 被阅读0次

    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)
    

    相关文章

      网友评论

          本文标题:angular2-chapter01

          本文链接:https://www.haomeiwen.com/subject/kkluzttx.html