Angular4 @Input() vs Component.inputs array

Viewed 702

From my understanding using

@Input() name: string;

And using the inputs array in the Component decorator as follows

@Component({
            ...
            inputs: ['bankName', 'id: account-id']
          })

Is basically the same. They both specify a binding input attribute on the component/directive element. Is there any difference between the two? If so whats the difference and when should each of them be used?

1 Answers

As per official style guide:

Do use the @Input() and @Output() class decorators instead of the inputs and outputs properties of the @Directive and @Component metadata

Answering your question there is no real difference between two approaches rather than readability and maintainability of your code. It's common practice to avoid using inputs and outputs properties.

Related