Attaching behavior to DOM elements with directives
In the course of creating applications, you will often find it useful to be able to attach component-style behavior to DOM elements, but without the need to have templating. If you were to attempt to construct an Angular 2 component without providing a template in some way, you will meet with a stern error telling you that some form of template is required.
Here lies the difference between Angular 2 components and directives: components have views (which can take the form of a
@View decorator), whereas directives do not. They otherwise behave identically and provide you with the same behavior.
The code, links, and a live example of this are available at http://ngcookbook.herokuapp.com/3292/ ...