Angular2-编写一个简易的组件
2017-06-04 23:59
253 查看
Angular2组件可以这么理解:编写一个类,然后在类的上面用组件装饰器装饰一下,这个类就成组件了。
所以编写组件分两步:1)编写类;2)编写装饰器
1)编写类:
2)在类上面编写装饰器:
完整代码如下:
同理,模板、指令、服务、管道也可以这么理解。
所以编写组件分两步:1)编写类;2)编写装饰器
1)编写类:
export class SimpleComponent {}
2)在类上面编写装饰器:
@Component({ selector: 'simple-component', template: `Hello Simple Component!` })
完整代码如下:
@Component({ selector: 'simple-component', template: `Hello Simple Component!` })
export class SimpleComponent {}
同理,模板、指令、服务、管道也可以这么理解。
相关文章推荐
- React编写一个简易的评论区组件
- 如何编写一个完整的Angular4 FormText 组件
- 一个定制计数器组件的编写
- 一个没有MYSQL数据库支持的简易留言本的编写
- 异步Socket编写的一个简易的聊天室
- JAVA--编写一个JFrame,标题为“计算的窗口”,在该窗口中组件的布局是FlowLayout。窗口中添加两个文本区,当我们在一个文本区中输入若干个数时,另一个文本区同时对输入的数进行求和运算并求
- java--第十周--任务二 编写一个JFrame,在该窗口中组件的布局是FlowLayout。窗口中添加两个文本区,当我们在一个文本区中输入若干个数时,另一个文本区同时对输入的数进行
- 从零开始编写一个flex组件。FLEX自定义控件。
- 用VB编写一个可以在ASP环境下调用的运行CMD命令的组件
- 从零开始编写一个flex组件
- 用C#编写一个进程外的COM组件
- 从零开始编写一个flex组件。FLEX自定义控件。
- 一个没有MYSQL数据库支持的简易留言本的编写
- 一个用C#编写的自动读写配置文件的开源组件--V1.0.2版本
- 一个用C#编写的自动读写配置文件的开源组件
- 习题10:参照Windows系统“附件”中的“计算器”,自行编写一个简易的计算器。要求:可以实现由0~4构成的整数的加减运算。
- 一个简易的打字速度测量----C编写
- 从零开始编写一个flex组件。FLEX自定义控件。
- 一个没有MYSQL数据库支持的简易留言本的编写
- 从零开始编写一个flex组件。FLEX自定义控件