您只需要稍作改动:
http://plnkr.co/edit/eP5fiFrWvcoVveYWAQzr?p=preview
var text = attrs['qtipContent'];
var title = attrs['qtipTitle'];
这是整个指令:
app.directive("myQtip", function () {
return function (scope, element, attrs) {
/******* This is what's different from myQtip *********/
var text = attrs['qtipContent'];
var title = attrs['qtipTitle'];
/******************************************************/
scope.qtipSkin = (attrs.skin ? "qtip-" + attrs.skin : "qtip-dark");
element.qtip({
content: {
text: text,
title: title
},
style: {
classes: scope.qtipSkin + " qtip-rounded qtip-shadow "
},
show: {
event: 'click mouseover',
solo: true
},
hide: {
event: (scope.closeButton == true ? "false" : "click mouseleave"),
delay: 300,
fixed: (($(this).hover || attrs.fixed) ? true : false), //prevent the tooltip from hiding when set to true
leave: false
},
position: {
viewport: $(window),// Keep it on-screen at all times if possible
target: (attrs.target ? attrs.target :"event"),
my: "bottom center",
at: "top center"
}
});
scope.$on("$destroy", function () {
$(element).qtip('destroy', true); // Immediately destroy all tooltips belonging to the selected elements
});
$('[my-qtip]').css("display", "inline-block");
}
});