angular学习—组件

组件:

vue组件:xxx.vue

react组件:xxx.js+xxx.css

angular组件:xxx.ts+xxx.css+xxx.html

 

angular的装饰器:

@ngModule:angular的一个模块化。装饰angular的app.module.ts文件内的AppModule类。

参数:

declarations:注册组件的地方
imports:注册项目用到的核心功能模块
providers:注册相关服务的
bootstrap:指定页面上初始渲染的组件


angular的组件装饰器:

@Component({
  selector: 'app-root', //组件的名字
  templateUrl: './app.component.html',//当前组件的html模板
  styleUrls: ['./app.component.css'] //当前组件的样式
})
export class AppComponent { title
= 'angularpro';  //类的属性 }

通过@component这个装饰器,将AppComponent类装饰为一个组件。

 

vue和react和angular的html模板的区别:
vue和react必须要有一个根节点,但angular不需要根节点。

posted @ 2018-12-05 19:11  健伟博客  阅读(360)  评论(0编辑  收藏  举报