【问题标题】:Angular strap tooltip visible by default角带工具提示默认可见
【发布时间】:2015-01-09 11:09:28
【问题描述】:

我使用http://mgcrea.github.io/angular-strap/#/tooltips#tooltips

我不能使用 Scope 方法($show()$hide())。请帮帮我。我怎样才能使用这种方法?

我已输入ng-repeat

 <div ng-repeat="item in data.queue" >

    <input type="text" maxlength="40"  bs-tooltip data-animation="am-flip-x" data-title="{{item.file.tooltip_title}}"> 

<div>

如果 item.file.flag=== true,我需要设置可见的工具提示,然后隐藏超过 5 秒的工具提示。

【问题讨论】:

    标签: angularjs angular-strap


    【解决方案1】:

    要获得 show() 和 hide() 方法,您必须在 javascript 端完成所有操作。像这样的:

    标记

    <div id="div1">some</div>
    

    指令

    app.directive('someThing', ['$tooltip', '$timeout', function($tooltip, $timeout){
        return {
            link: function($scope){
                $scope.someFunction = function (item){
                    $timeout(function(){
                        var target = angular.element(document.getElementById('div1'));
                        var myTooltip = $tooltip(target, { title:'tip!!', trigger:'manual', placement:'top'});
                        myTooltip.$promise.then(function() { myTooltip.show(); });
    
                        $timeout(function(){
                            myTooltip.$promise.then(function() { myTooltip.hide(); });
                        }, 4000);
                    }, 1500);
                };
            }
        };
    }]);
    

    【讨论】:

      【解决方案2】:

      Angular 解决问题的方法是使用,例如,data-bs-show="item.file.flag"

      它会在item.file.flag == true 时显示您的工具提示。

      bsShow 属性需要一个布尔值,因此如果您需要在 5 秒后隐藏,您可能会有另一个标志并在此时间后使用 $timeout 将其设置为 false。

      可以使用$show()/$hide(),但它既棘手又丑陋,所以我会尽可能避免使用。

      【讨论】:

        猜你喜欢
        • 2010-10-24
        • 1970-01-01
        • 2011-03-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多