I try to parameterize the template of a page using a directive. I have an array of objects with a 'type' value. I want to use different templates when types are different.
Here is what I tried:
directive.js
angular.module('core')
.directive('mySolutionDisplay', function () {
return {
restrict: 'E',
scope: {
solution: '='
},
templateUrl: function (elem, attr) {
return 'path/to/template/solution-'+attr.type+'.template.html';
}
};
});
view.html
<div class="row">
<my-solution-display type="vm.solution[0].type" solution="vm.solution"></my-solution-display>
</div>
I get the following error :
angular.js:11706 Error: [$compile:tpload] Failed to load template: path/to/template/solution-vm.solution[0].type.template.html
I tried replacing type="vm.solution[0].type"
by type="{{vm.solution[0].type}}"
but it just added the curly brackets to the error message.