0 day streak
javascript / beginner
Snippet

Passing Data with @Input

The @Input decorator allows a component to receive data from its parent. This is a fundamental way to share information between different parts of the app.

snippet.js
javascript
1
2
3
4
5
6
import { Component, Input } from '@angular/core';
@Component({ ... })
export class ProfileComponent {
@Input() username = 'Guest';
}
angular
Breakdown
1
@Input() username
Marks this property as an input that can be set by a parent component.