0

Which approach to passing static string values as inputs to an Angular component is considered a better practice and is more performant?

Pass input via an attribute

<some-component color="red" />

or pass it explicitly

<some-component [color]="'red'" />

Does either of them result in fewer CD checks, ngOnchanges calls, or has DOM access advantages?

2
  • You might want to repost this question and choose the type "advice" or "best practices" for your question Commented 2 days ago
  • 1
    Consider that the difference is negligeable. Use binding to pass anything that isn't a string, if the string doesn't change, go for a regular attribute Commented 2 days ago

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.