简体   繁体   English

如何自动将“aria-描述的属性”添加到 uib-tooltip

[英]How to add "aria-describedby attribute" to the uib-tooltip automatically

在我们的应用程序中(它是一个 angularJs),我们在很多地方都有“uib-tooltip”,所以我想让它成为一段简单的代码,如果“uib-工具提示”在那里。

You can add attributes to the element that has the uib-tooltip directive on it.您可以向具有 uib-tooltip 指令的元素添加属性。 Just add the "uibTooltip" to a module of yours.只需将“uibTooltip”添加到您的模块中即可。 This will add additional functionality on top of what the library does.这将在库的功能之上添加额外的功能。

.directive('uibTooltip', function () {
  return {
    link: function (scope, element, attrs) {
      attrs.$set('aria-describedby', 'Whatever text you want.');
    }
  }
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM