I have a number of angular 1.5 components that all take the same attributes and data structure. I think they could be re-factored into a single component, but I need a way to dy
You have to have the switching logic somewhere in any case so why not simply have it in a parent component template?
Having clean and understandable AngularJS template in that case is IMO more valuable than a bit of repetition:
Even if you change the myComponentDef.type on the fly, the components in the switch will correctly call their respective $onDestroy
and $onInit
methods and load data as expected - no magic, no voodoo.