directive('addSubtitle', function($compile) {
var subtitleTemplate =
'<div class="entry-photo">' +
'<h2> </h2>' +
'<div class="entry-img">' +
'<span>' +
'<a href="">' +
'<img ng-src="" alt="entry photo">' +
'</a>' +
'</span>' +
'</div>' +
'' +
'<div class="entry-text">' +
'<div class="entry-title"></div>' +
'<div class="entry-copy"></div>' +
'</div>' +
'</div>';
var getTemplate = function(contentType) {
var template = '';
switch(contentType) {
case 'subtitle':
template = subtitleTemplate;
break;
case 'video':
template = videoTemplate;
break;
case 'notes':
template = noteTemplate;
break;
}
return template;
};
var linker = function(scope, element, attrs) {
element.click(function(){
console.log(attrs.contentType);
console.log(scope.type);
$compile(getTemplate(scope.type.type));
});
};
return {
restrict: "EA",
scope: {
type: '=contentType'
},
replace: false,
link: linker
};
});