remind101 / angular-tooltip

Simple and extensible tooltips for angularjs
MIT License
41 stars 34 forks source link

Allow template in addition to templateUrl #4

Closed christopherbahr closed 10 years ago

christopherbahr commented 10 years ago

Probably not useful for most people but I needed it in my project.

ejholmes commented 10 years ago

Awesome, thanks!

ramirez commented 10 years ago

How can I use this option?

christopherbahr commented 10 years ago

When you're writing your link: function you just swap template for templateUrl and give it a string with your tooltip in it. Just make sure you have a div with class tooltip surrounding it. Something like

app.directive('myTooltip', function($tooltip) {
  return {
    restrict : 'EA',
    link : function(scope, elem) {
      var tooltip = $tooltip({
        target: elem,
        scope: scope,
        template: '<div class="tooltip"> This is my tooltip </div>',
      });
      elem.hover(function(){
        $scope.apply(tooltip.open);
      }, function () {
        $scope.apply(tooltip.close);
      });
    }
  };
});
ramirez commented 10 years ago

Thanks!

On Fri, Jul 18, 2014 at 3:05 PM, christopherbahr notifications@github.com wrote:

When you're writing your link: function you just swap template for templateUrl and give it a string with your tooltip in it. Just make sure you have a div with class tooltip surrounding it. Something like

app.directive('myTooltip', function($tooltip) { return { restrict : 'EA', link : function(scope, elem) { var tooltip = $tooltip({ target: elem, scope: scope, template: '

This is my tooltip
', }); elem.hover(function(){ $scope.apply(tooltip.open); }, function () { $scope.apply(tooltip.close); }); } }; });

— Reply to this email directly or view it on GitHub https://github.com/remind101/angular-tooltip/pull/4#issuecomment-49428147 .