To display another template based on value.type , you can use the ng-switch :
<div ng-switch="value.type"> <div ng-switch-when="type1"> //...template for type 1 here... </div> <div ng-switch-when="type2"> //...template for type 2 here... </div> </div>
In addition, if I understood your second question: the manipulation of an uncompiled directive should be performed in the compile function, all manipulations that occur after compilation should go in the link function.
Documents for ngSwitch
EDIT : +1 for Sebastian to understand what you wanted. However, what it offers is basically reinventing the wheel, as it essentially compiles and inserts the template manually (which ngSwitch means to you). In addition, you can access the attributes that you put in your directive through the attrs argument of the link function.
link source share