I want to create tooltips in an ng-repeat with angular-tooltips. The content of the tooltips has to be dynamically. What I already have is something like this:
View:
<div ng-repeat="region in regions">
<a tooltips tooltip-html="{{ myCtrl.generateTooltip(region) }}">HOVER</a>
</div>
Controller:
function generateTooltip(region) {
// generate some html here
var content = "<b>HELLO WORLD!</b>";
return $sce.trustAsHtml( content );
}
The tooltip is shown and working, but I get the following error in console (which I don't want to see :-))
Error: [$parse:syntax] Syntax Error: Token '<' not a primary
expression at column 1 of the expression [<b>HELLO WORLD!</b>]
starting at [<b>HELLO WORLD!</b>].
- What is wrong with my code?
- Is it possible to use a view as the tooltip instead of generating the HTML in the controller? There is an attribute
tooltip-view, but I don't know how to pass myregionvariable to it.
{{ }}here; the return value of the function isn't an expression that angular needs to evaluate.{{ }}, the content of the tooltip is "myCtrl.generateTooltip(region)" ;-)Error: [$sce:unsafe] Attempting to use an unsafe value in a safe context., although I am using$sce.trustAsHtml()...angular-sanitize.js.