Angular4的输入属性
来源:互联网 发布:php 随机昵称 编辑:程序博客网 时间:2024/06/06 18:42
输入属性通常用于父组件向子组件传递信息
举个栗子:我们在父组件向子组件传递股票代码,这里的子组件我们叫它app-order
首先在app.order.component.ts中声明需要由父组件传递进来的值
order.component.ts
...@Input()stockCode: string@Input()amount: string...
order.component.html
<p>这里是子组件</p><p>股票代码为{{stockCode}}</p><p>股票总数为{{amount}}</p>
然后我们需要在父组件(app.component)中向子组件传值
app.component.ts
...stock: string...
app.component.html
<input type="text" placeholder="请输入股票代码" [(ngModel)]="stock"><app-order [stockCode]="stock" [amount]="100"></app-order>
这里我们使用了Angular的双向数据绑定,将用户输入的值和控制器中的stock进行绑定。然后传递给子组件,子组件接收后在页面显示。
0 0
- Angular4的输入属性
- angular4输入属性@input
- Angular4中的输出属性
- angular4输出属性@Output
- angular4的rollup
- 对angular4的认识
- angular4的对象
- Angular4的表单
- angular4的初认识
- Angular4中关于component组件如何获取前端页面用户输入的值
- Angular4
- Angular4
- Angular4 中常用的指令
- Angular4 树组件的使用
- angular4 +node+express 的搭建
- angular2到angular4的过度
- angular4中样式的绑定
- Angular4的双向数据绑定
- java链接ftp服务器
- 为什么说String 是不可变的?
- 函数指针和函数指针数组
- QML中的JavaScript用法详解(一)-----在qml中将字符串类型数据转换为整型数据
- 表空间的属性+修改属性+查询所有表空间名称,状态
- Angular4的输入属性
- SQL索引优化
- 数据结构之线性表——双向链表
- 非常全面的 Android Bitmap 知识点梳理
- yum Error: rpmdb open failed
- iOS 添加 UA
- EA&UML日拱一卒--序列图(Sequence Diagram)::时间约束
- 来看看 random_state 这个参数
- Linux常用命令(三)