0

I have just started to dabble in the whole child and parent component communication side of things in Angular 4 and I have noticed some older videos use the syntax input: [] rather than the more commonly seen @Input() syntax, is there any difference between the two? And if not, is there a preference?

2
  • Weird, ive never seen that. You have any links/examples? Commented May 2, 2018 at 14:56
  • 1
    @diopside I think I mis-understood the usage, all is clear to me now! Commented May 2, 2018 at 14:58

2 Answers 2

1

They mean two different things:

  • @Input() decorator that specifies that a certain property is passed to the current component from the parent component (I.e. @Input() highlightColor: string) - Docs
  • input: [] component property named input and of type Array - Docs

Notice that @Input() input: [] is perfectly valid syntax.

Sign up to request clarification or add additional context in comments.

Comments

0

@Input() is used when you pass some value from a parent component to the component itself.

The input:[] is a normal property with the name input

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.