The component does NOT replace .directive as @rek Żelechowski. So..
You cannot do anything with .component (), which you cannot do with .directive (). It aims to simplify the way we create “components,” which roughly means UI directives.
When can / should it be used?
Obviously, there are several cases where you cannot / do not use it:
- If you need a link function (although you rarely have to)
- If you want a directive without templates, for example. ng-click, which does not have a template or a separate area.
For all your other directives, this should work. And since it saves on the template and is less prone to errors, it is more convenient to use.
Despite all the new goodies, .component () cannot completely replace .directive ().
Pedro justo
source share