I have this directive
angular.module('starter.directive', [])
.directive('answer', ['Helper', function (Helper) {
return {
require: "logic",
link: function (scope, element, attrs, logicCtrl) {
var htm = '';
if(logicCtrl.test == 'a') {
htm = '<p>a</p>'
}
if(logicCtrl.test == 'b') {
htm = '<p>b</p>'
}
},
template: '' // somehow use htm here
}
}]);
I'm trying to use the htm
for the template
,
Any ideas?
You can just put
htm
intoscope
of directive and use it inside template.UPDATE
To compile html strings into template you need to use $compile service, just possible example: