Skip to content

Instantly share code, notes, and snippets.

@vicly
Created April 30, 2020 00:11
Show Gist options
  • Save vicly/fdd6ca6e10a5dd6073d583aebb65409b to your computer and use it in GitHub Desktop.
Save vicly/fdd6ca6e10a5dd6073d583aebb65409b to your computer and use it in GitHub Desktop.
[Angular数据绑定:方括号,圆括号,花括号] #Angular #Frontend

[]: 绑定属性

<div class="red">red</div>    // class为red
<div [class]="red">red</div>  // class为blue; 从变量red读取
 
//组件中
red: string = "blue";

(): 绑定事件

<div (click)="go()">gogo</div>
 
//组件中
go() {
 //...
}

{{}}: 插值

<div>{{good}}</div>   //<div>你好</div> 
 
//组件中
good: string = "你好";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment