简体   繁体   English

uib-tooltip作为Controller中的文本

[英]uib-tooltip as text in Controller

I have some problems with appending uib-tooltip to the view. 将uib-tooltip附加到视图时遇到一些问题。

Controller: ('v' is an array) 控制器:( “ v”是一个数组)

$scope.video_link = function (v) {
    var del = "";
    if(v.deleted == 1) {
        del = '<i class="fa fa-times" uib-tooltip="Video deleted"></i>';
    }
    var link = del+'<a href="'+v.video_id+'">' + v.video_name + '</a>';
    return $sce.trustAsHtml(link);
}

View: 视图:

<span ng-bind-html="video_link(v)"></span>

Everything works well but tooltip itself don't show up. 一切正常,但工具提示本身未显示。

I know I can move "uib-tooltip" to the view (and it works fine) but I need to build the whole link in Controller. 我知道我可以将“ uib-tooltip”移动到视图中(并且工作正常),但是我需要在Controller中构建整个链接。 Is it possible to made it work properly? 是否可以使其正常工作?

To make dynamically created by code md-elements to work you need to call 要使由代码md-elements动态创建的工作正常工作,您需要调用

componentHandler.upgradeAllRegistered();
which initializes all new bootstrap components added to the view ie those are added programatically 初始化所有添加到视图的新引导程序组件, ie those are added programatically

componentHandler.upgradeElement(elem)
if you want to initilize only 1 element 如果您只想初始化1个元素

ALSO make sure you call one of these functions after the element is added to the view and not before. 另外,还要确保你调用这些函数的元素被添加到该视图,而不是之前后。

componentHandler global object is created when you import uibootstrap library to your project. uibootstrap库导入项目时,将创建componentHandler全局对象。

componentHandler reference componentHandler参考

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

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