入门 Angular 2 杂记

1. 引入Angular2预定义类型

  import {Component,View,bootstrap} from "angular2/angular2";

2. 实现一个Angular2组件

  @Component({selector:"ez-app"})   // 通过selector属性,使用css选择器 渲染到的位置

  @View({template:"<h1>Hello,Angular2</h1>"})   //View, 通过template属性,指定渲染的模板

  class EzApp{}

3. 渲染组件到DOM

  bootstrap(EzApp);

 

上述相当于,

class EzApp {

}

EzApp.annotations = [

  new Component({selector: "ez-app"}),

  new View({template: "<h1>HELLO</h1>"})

];

 

posted @ 2016-05-09 15:19  爱学习的小赵同学  阅读(135)  评论(0)    收藏  举报