Skip to content

Instantly share code, notes, and snippets.

@renz45
Created June 17, 2014 14:14
Show Gist options
  • Save renz45/c117f0cd5b73a45e14e7 to your computer and use it in GitHub Desktop.
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.
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