I\'m working on a set of angular directives and I want to load the correct template based on the presence or value of an attribute.
One of the solutions for this is to use an ng-include inside the template file.
The first attribute inside of the template file will have something like :
In your directive code you would write something like :
scope : {direction : "="},
link : function(scope,element,attrs)
{
scope.getTemplate = function(){
if(scope.direction === "horizontal")
{
return "horizontal.html";
}
return "vertical.html";
}
}
Hope this helps!