Menu
CoddyTech

Component Inputs

Part of the Fundamentals section of Coddy's Angular journey. Lesson 27 of 55.

An input lets a parent configure a child. The decorator marks the field as data that the child accepts. Here the parent supplies a value using a property binding on the child selector.

// Child class field: @Input() label="Default";
// Child template: <p>{{label}}</p>
// Parent template: <name-card [label]="'Fern'"></name-card>

Use the Input decorator to declare an incoming field. Bind expressions for values that come from parent data; a plain text attribute supplies literal text. The child renders its input but does not own the parent state.

challenge icon

Challenge

Medium

Pass the parent name signal into ProductCard and render it inside a. Renaming changes Pears to Plums in the child.

Edit the supplied files. Press Run preview to refresh the preview after edits, then use Check or Run code to grade your work. Keep the requested element IDs.

Try it yourself

<!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="stylesheet" href="styles.css"></head><body><app-root></app-root><script type="module" src="main.ts"></script></body></html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals