Skip to content

Add Input Property to Component

Tyler Ruff edited this page Jun 14, 2022 · 1 revision

In Angular, you can dynamically or statically pass data to components using a "Input" property. This allows you to pass data or a variable to the component.

  1. Add import to component.ts:
import { ... Input ... } from '@angular/core';
  1. Add the input parameter, right after the class declaration:
@Input() page = '/default';
  1. Finally, you can use the input within the component.html file:
<app-component [page]="id"></app-component>
Clone this wiki locally