Angular

Last Updated: 6/19/2023

Input Properties

  • To mark the field as input property so that it can be used in property binding

Option 1:

  • Input decorator is used to mark field and properties as input properties
  • Preferred way
  • import @input
	import { Input } from '@angular/core';
  • add @Input decorator to the property
	@Input() isSelected: boolean;
  • Use in property binding
	<favorite [isSelected]="post.selected"></favorite>

Option 2:

  • In component decorator add input property name
  • The name should match the field name. if the name differs it will fail
  • Not preferred
	@Component({
		inputs: ["isSeelcted"]
	})