Getting Highcharts tooltip to return an angular directive?

不想你离开。 提交于 2019-12-04 17:37:49

You are giving the formatter a dom element, and it wants an html string. Converting it back to html works, but it seems like an inefficient way to accomplish your goal.
http://jsfiddle.net/ue3x49tt/3/

formatter: function () {                  
    return $compile("<pm-error-rate-tooltip></pm-error-rate-tooltip>")($scope).html();                   

}

I've got a trouble about that, I can't give a paremeter to the directive. http://jsfiddle.net/tux82Lvw/

return $compile("<pm-error-rate-tooltip test='test'></pm-error-rate-tooltip>"

By the way, the directive scope is ok, the only trouble is with the template compilation

//datacompliance
angular.module('myapp').directive('pmErrorRateTooltip', function() {
  return {
  scope:{test:'='},
  link:function($scope){
    console.log($scope)
  },
  restrict: 'E',
    template: '<b>{{test}}</b>'
  };
});

I was able to get this to work with parameters. I forked user2422856 jsfiddle from their answer to show how http://jsfiddle.net/xhfgzfps/1/ .

I had to compile the directive, then do a $scope.$digest() and finally return the markup using .html(). I haven't been able to figure out how to do this without manually triggering a digest.

$scope.test = "Dont work"
var toolTip = $compile("<pm-error-rate-tooltip test='test'></pm-error-rate-tooltip>")($scope);
$scope.$digest();
return toolTip.html();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!