Hey there, I have a question about using a scope variable in a dynamically generated template URL. Here's what I tried:
HTML
<my-directive type="{{ type }}"></my-directive>
JS
angular.module('myApp', [])
.directive('myDirective', function () {
return {
templateUrl: function (tElement, tAttrs) {
return 'templates/myDirective.' + tAttrs.type + '.html';
};
};
});
I thought tAttrs.type
would give me the value of $scope.type
, but it actually returned {{ type }}
. This resulted in a templateUrl of
templates/myDirective.{{ type }}.html
.
Any suggestions on how to get the actual value of the scope variable instead of the raw text?