1

I'm very confused. Can an Angular 2 Component be reused outside of the Angular scope just like a Web Component?

Or maybe it's more than that?

twernt
  • 20,271
  • 5
  • 32
  • 41
rdupz
  • 2,204
  • 2
  • 13
  • 21

1 Answers1

1

The intention was to make Angular components reusable Web components like Polymer elements and it was communicated this way a while back.

Currently support for this is only very limited. Each Angular root component (the outer-most Angular component) is a distinct Angular application and the root component is quite limited.

  • @Input() doesn't read attribute values while it does inside another Angular component
  • @Attribute() annotation for a constructor argument doesn't inject the attribute value like it does when used inside another Angular2 component
  • transclusion doesn't work <ng-content> to wrap existing HTML with an Angular component
  • Each root component has its own injector for dependency injection.

This might be an open task for later but there is currently no concrete information available as far as I know.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567