Created
June 17, 2014 14:14
-
-
Save renz45/c117f0cd5b73a45e14e7 to your computer and use it in GitHub Desktop.
An example of wrapping the Twitter Bootstrap tooltip function in a directive to be used within an angular project. Note the `scope.$on '$destroy'` part that cleans up the tooltip and prevents memory leaks.
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
angular.module('myApp').directive 'tooltip', -> | |
restrict: 'A' | |
scope: {} | |
link: (scope, element, attrs)-> | |
$(element).tooltip({ | |
animation: attrs.animation | |
html: attrs.html | |
placement: attrs.placement | |
selector: attrs.selector | |
title: attrs.title | |
trigger: attrs.trigger | |
delay: attrs.delay | |
container: attrs.container || 'body' | |
}) | |
scope.$on '$destroy', -> | |
$(element).tooltip('destroy') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment