Angular

Last Updated: 6/19/2023

Component API

  • We ues property binding with square bracket syntax to bind properties of DOM object to fields or properties in you host component
<img [src]="imageUrl">
  • src property is an input to the DOM object we use this to supply data/state
  • We use event binding to respond to events raised from the DOM object
<button (click)="onClick()"><button>
  • In angular template in order to use property binding you need to define the property or field as input property. Just specifying public is not enough.
  • To add support for event binding you need to define output property
  • In order to make component more reusable we need to add a bunch of input and output properties
  • We use Input properties to pass data/state to the component
  • We use Output properties to raise events from the component
  • The combination of input and output properties for a component makeup the public API of that component