Reputation: 1986
I have the following directive I use to initialize the timeago plugin.
Directives.directive('timeago', function() {
return function(scope, element, attrs) {
$(element).attr('title', scope.post.utc_posted);
$(element).timeago();
}
});
How could I use/pass $log
inside the function I'm returning?
Upvotes: 3
Views: 1696
Reputation: 24506
You can just inject it the normal way. BTW element
is already a jQuery variable and does not need $(element)
- providing you're loading jQuery before Angular.
Directives.directive('timeago', function($log) {
return {
link: function(scope, element, attrs) {
element.attr('title', scope.post.utc_posted);
element.timeago();
}
}
});
Upvotes: 7