angularjsangularjs-ng-transcludetransclusioncomponentmodel

What is the difference between the component architecture and multi-transclusion model in AngularJS?


I understand what the component architecture is, I don't understand how it is different from the multi-transclusion model. Can someone please explain?


Solution

  • The difference is that components are used to encapsulate logic and define how a custom HTML element is rendered. Multi-transclusion is/can be a part of a component. It tells where arbitrary text/HTML/... is placed when the component is rendered.

    This is especially useful if you want to create a component to layout your application. I think the official documentation is a good example for that: https://docs.angularjs.org/api/ng/directive/ngTransclude#multi-slot-transclusion