# Sharing data between child and parent directives and components A common pattern in Angular is sharing data between a parent component and one or more child components. To implement this pattern use the `@Input()` and `@Output()` directives.
See the for a working example containing the code snippets in this guide.
Consider the following hierarchy: ```html ``` The `` serves as the context for the ``. `@Input()` and `@Output()` give a child component a way to communicate with its parent component. `@Input()` lets a parent component update data in the child component. Conversely, `@Output()` lets the child send data to a parent component. {@a input} ## Sending data to a child component The `@Input()` decorator in a child component or directive signifies that the property can receive its value from its parent component. To use `@Input()`, you must configure the parent and child. ### Configuring the child component To use the `@Input()` decorator in a child component class, first import `Input` and then decorate the property with `@Input()`, as in the following example. In this case, `@Input()` decorates the property item, which has a type of `string`, however, `@Input()` properties can have any type, such as `number`, `string`, `boolean`, or `object`. The value for `item` comes from the parent component. Next, in the child component template, add the following: ### Configuring the parent component The next step is to bind the property in the parent component's template. In this example, the parent component template is `app.component.html`. 1. Use the child's selector, here ``, as a directive within the parent component template. 2. Use [property binding](guide/property-binding) to bind the `item` property in the child to the `currentItem` property of the parent. 3. In the parent component class, designate a value for `currentItem`: With `@Input()`, Angular passes the value for `currentItem` to the child so that `item` renders as `Television`. The following diagram shows this structure: The target in the square brackets, `[]`, is the property you decorate with `@Input()` in the child component. The binding source, the part to the right of the equal sign, is the data that the parent component passes to the nested component. ### Watching for `@Input()` changes To watch for changes on an `@Input()` property, use `OnChanges`, one of Angular's [lifecycle hooks](guide/lifecycle-hooks). See the [`OnChanges`](guide/lifecycle-hooks#onchanges) section of the [Lifecycle Hooks](guide/lifecycle-hooks) guide for more details and examples. {@a output} ## Sending data to a parent component The `@Output()` decorator in a child component or directive lets data flow from the child to the parent. `@Output()` marks a property in a child component as a doorway through which data can travel from the child to the parent. The child component uses the `@Output()` property to raise an event to notify the parent of the change. To raise an event, an `@Output()` must have the type of `EventEmitter`, which is a class in `@angular/core` that you use to emit custom events. The following example shows how to set up an `@Output()` in a child component that pushes data from an HTML `` to an array in the parent component. To use `@Output()`, you must configure the parent and child. ### Configuring the child component The following example features an `` where a user can enter a value and click a `