I\'m creating a directive with template URL. I want to set the template URL dynamically based on user_role. Any idea?
Heres my directive code:
RatingRX.d
you can manipulate ng-include
as a template
html:
js:
app.directive('headermenu', function() {
return {
restrict: 'E',
scope: {
userRole : '='
},
link: function($scope)
{
$scope.$watch('userRole', function(userRole)
{
if (userRole && userRole.length)
{
$scope.dynamicTemplateUrl = 'assets/common/headerMenu' + userRole + '.html';
}
});
},
template: ' '
};
});
html:
js:
app.directive('headermenu', function() {
return {
restrict: 'E',
scope: {
path : '@'
},
template: ' '
};
});