Search code examples
javascriptangulartypescriptfrontendangular-components

How do I make an @Input property readonly in an Angular component?


How would I make this @Input property read only in an angular component?

@Input() name: string;


Solution

  • You simply need to use the readonly qualifier as below, between the @Input decorator and the name identifier.

    @Input() readonly name: string;