angularjs - 有没有办法在 Angular Js 自定义指令中添加“uib-tooltip-html”作为属性?
问题描述
我创建了一个 AngularJS 自定义指令来更改元素的文本。
angular.module('main').directive('showAB', ["$sce", "$compile", ($sce, $compile) => {
return {
restrict: 'A',
scope : {
textA: "=",
textB: "=",
showA: "="
},
link: (scope, $elem, attrs) => {
var displayText = !scope.showA ? scope.textA : scope.textB;
$elem.html(displayText);
$elem.removeAttr("show-a-b");
$elem.attr("uib-tooltip-html", displayText);
$compile($elem)(scope);
}
}
}]);
这不是实际的代码,只是创建了一个简单的指令来解释这个问题。它将根据 showA 变量显示 textA 或 textB。以 html 格式显示的文本应显示为该元素的工具提示。
有没有办法做到这一点?如果我用 uib-tooltib 替换 uib-tooltip-html,它工作正常,但由于文本是 html,它不会在屏幕上正确显示值。
解决方案
推荐阅读
- python - Python recursive function wont change list defined in main()
- ios - iOS 通过单击 TableView 中的另一个部分来折叠/展开部分
- regex - Python 3 Pandas 通过正则表达式和通配符过滤数据框
- javascript - 在 SVG 中是否可以推送/弹出矩阵变换?
- java - 运行 jar 时找不到或加载主类
- oracle - 是否可以在 SQLPLUS 中设置默认列格式?
- java - 如何在 Spring Boot 中注册 Alexa V2 Servlet
- redirect - 如何从控制器操作重定向发布请求?
- c# - 在 C# 类中从另一个泛型类型参数暗示一个泛型类型参数
- azure - 将预编译的 f# 函数部署到 Azure Functions v2