what i am trying to do is create the following markup:
<current-user />
this directive should simply inject the current users username just like a binding expression {{currentUser.name}}
here is what i have but i am losing my span tag at the end for the caret
:
HTML:
<a href="" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-user"></i>
<current-user />
<span class="caret"></span>
</a>
Javascript:
app.directive('currentUser', function ($rootScope, auth) {
return {
restrict: 'E',
transclude: true,
compile: function (elem) {
$rootScope.$watch('auth.profile', function (profile) {
if (profile) {
elem.html(profile.email);
}
});
}
}
});
any help would be greatly appreciated