Is there a way to conditionally load the template of a directive? For example:
.directive('truncate',["$window", function($window, $compile){
return {
restrict: 'A',
templateUrl: 'template/truncate.html',
link: function (scope, element, attrs) {
var height = element[0].offsetHeight;
var shouldBetruncated = height > 200;
if(shouldBetruncated){
// Load my template here if condition is met
}
}
}
}])
.run(function ($templateCache) {
$templateCache.put('template/truncate.html',
'template code'
);
})
Any suggestions on how to achieve this?