Add Inputs to Angular Directives

InstructorJohn Lindquist

Share this video with your friends

Send Tweet

The @Input decorator allows you to pass values into your @Directive so that you can change the value of the Directive each time that it is used. Using @Input makes your Directives much more flexible and reusable so they can adapt to many different situations.

Hero Katzuki
~ 7 years ago

:) Clarification request :) With respect to the FirstDirective in the video. Is the usage of "@Input first" with the " selector: '[first]' " a special case when you want to "enable"/use property binding with a directive? Meaning, anytime we want to use property binding our custom directive we have to, by default make the directive's selector use brackets "[selector-name]" notation because ng2 template property binding syntax needs bracket notation and we need to make our custom directive's "@Input" match its "selector-name" between the brackets? In summary, is it correct to say that; when we want to use property binding on our custom directive, we have to make our custom directive conform to the ng2 template property binding syntax requirements?

Thanks for these great videos btw :). They are very helpful.