Sajan Sajan - 23 days ago 5x
Javascript Question

Angular directive scope value

<tab page="book"> </tab>
<tab page="dial"> </tab>
<tab page="groupe"> </tab>
<tab page="log"> </tab>
<tab page="star"> </tab>

As you can see i have a directive named tab, and this tab have an attribute page,

i need to change the templateUrl based on the value of page attribute

if the page value is
then the templateUrl should be
templateUrl: 'tab/abc.html',

here is my directive code

contactBook.directive('tab', function() {
let m = 'tab/default.html';
return {
restrict: 'E',
scope: {
page: '@',
templateUrl: m,
link: function(scope, element, attributes) {
m = "tab/" + + ".html";

is this logically possible..? or any alternative methode to done this..?

templateUrl: function(elem,attrs) {
    return "tab/" + + ".html" || 'tab/default.html';