Created
June 18, 2013 11:28
-
-
Save vladimir-ivanov/5804636 to your computer and use it in GitHub Desktop.
AngularJs Tooltip with html content directive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jshint bitwise:true, camelcase:true, curly:true, eqeqeq:true, forin:true, latedef:true, newcap:true, noarg:true, | |
noempty:true, nonew:true, undef:true, unused:true, strict:true, browser:true, camelcase:false */ | |
/*globals | |
$: false | |
*/ | |
/*exported | |
ToolTipDirective | |
*/ | |
// needs to be made generic at some point | |
var ToolTipDirective = function ($compile) { | |
"use strict"; | |
return { | |
link: function (scope, element) { | |
var el = $(element), | |
template = el.find('script.template').html(), | |
title = ''; | |
if (template) { | |
title = $compile(template)(scope); | |
} else { | |
title = el.attr('title'); | |
} | |
el.tooltip({ | |
title: title, | |
placement: "right" | |
}); | |
} | |
}; | |
}; | |
ToolTipDirective.$inject = ['$compile']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment