- 数据绑定就是将组件类中的数据显示在组件模板中,当组件类中的数据发生变化时会自动被同步到组件模板中(数据驱动 DOM )
- 在 Angular 中使用差值表达式进行数据绑定,即 {{ }} 大胡子语法
```typescript
// src/app/app.component.html
{{ message }}
{{ getInfo() }}
{{ a == b ? ‘相等’ : ‘不等’ }}
{{ ‘Hello Angular’ }}
```typescript// src/app/app.component.tsexport class AppComponent {message: string = 'angular-test';htmlSnippet: string = '<h1>htmlString</h1>'a: number = 1b: number = 1getInfo() {return '我是 getInfo 方法中返回的数据'}}
- 页面显示

