4

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 Answer 1

4

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.

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

1 Comment

Thanks should of went straight to the style guide instead of trying to search for this on google.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.