# Binding syntax Data binding automatically keeps your page up-to-date based on your application's state. You use data binding to specify things such as the source of an image, the state of a button, or data for a particular user.
See the for a working example containing the code snippets in this guide.
## Data binding and HTML Developers can customize HTML by specifying attributes with string values. In the following example, `class`, `src`, and `disabled` modify the `
`, ``, and ``. To control the state of the button, set the `disabled` property instead. #### Property and attribute comparison Though you could technically set the `[attr.disabled]` attribute binding, the values are different in that the property binding must be a boolean value, while its corresponding attribute binding relies on whether the value is `null` or not. Consider the following: <input [disabled]="condition ? true : false"> <input [attr.disabled]="condition ? 'disabled' : null"> The first line, which uses the `disabled` property, uses a boolean value. The second line, which uses the disabled attribute checks for `null`. Generally, use property binding over attribute binding as a boolean value is easy to read, the syntax is shorter, and a property is more performant. To see the `disabled` button example in a functioning application, see the . This example shows you how to toggle the disabled property from the component. ## Types of data binding Angular provides three categories of data binding according to the direction of data flow: * From source to view * From view to source * In a two-way sequence of view to source to view | Type | Syntax | Category | |:--- |:--- |:--- | | Interpolation
Property
Attribute
Class
Style | {{expression}} [target]="expression" | One-way from data source to view target | | Event | (target)="statement" | One-way from view target to data source | | Two-way | [(target)]="expression" | Two-way | Binding types other than interpolation have a target name to the left of the equal sign. The target of a binding is a property or event, which you surround with square bracket \(`[ ]`\) characters, parenthesis \(`( )`\) characters, or both \(`[( )]`\) characters. The binding punctuation of `[]`, `()`, `[()]`, and the prefix specify the direction of data flow. * Use `[]` to bind from source to view * Use `()` to bind from view to source * Use `[()]` to bind in a two-way sequence of view to source to view Place the expression or statement to the right of the equal sign within double quote \(`""`\) characters. For more information see [Interpolation](guide/interpolation) and [Template statements](guide/template-statements). ## Binding types and targets The target of a data binding can be a property, an event, or an attribute name. Every public member of a source directive is automatically available for binding in a template expression or statement. The following table summarizes the targets for the different binding types. | Type | Target | Examples | |:--- |:--- |:--- | | Property | Element property
Component property
Directive property | `alt`, `src`, `hero`, and `ngClass` in the following: | | Event | Elementevent
Component event
Directive event | `click`, `deleteRequest`, and `myClick` in the following: | | Two-way | Event and property | | | Attribute | Attribute \(the exception\) | | | Class | `class` property | | | Style | `style` property | | @reviewed 2022-02-28