生成组件:
ng new component simple-test
使用模板表达式:
<div [xxx1]="xxx2"></div>
总结 xxx1:
1. 原生DOM元素本身的 Property,比如 div 元 id 这个Property
<input [(ngModel)]="eleId"> <div [id]="eleId"></div>
xxx1 就是 id了

插一句,经常得干的事,否则用不了 ngModel,赶紧写上好了:


2. Angular 组件对外暴露的属性
子组件暴露一个progress的属性
<div class="parent"> <div [style.width.%]="progress" class="child"></div> </div>
@Input()
progress:number = 30;
父组件绑定到的属性,这时候就是子组件暴露的属性,xxx1 就是 progress
Progress: <input [(ngModel)]="progress"><br><br> <app-simple-test [progress]="progress | number"></app-simple-test>
效果:


3. 原生DOM元素的 Attribute Class Style
Attribute: [attr.xxx]
例子:
col span: <input [(ngModel)]="colSpan"> <table> <tr> <td>aaa</td> <td>bbb</td> <td>ccc</td> </tr> <tr> <td [attr.colspan]="colSpan | number">111</td> </tr> </table>
注意这句:

原文:https://www.cnblogs.com/chenyingzuo/p/12545266.html