Good way to dynamically open / close a popover (or tooltip) using angular, based on expression?

前端 未结 6 1265
既然无缘
既然无缘 2020-12-01 07:50

I have a form that is wired into angular, using it for validation. I am able to display error messages using ng-show directives like so:



        
6条回答
  •  心在旅途
    2020-12-01 08:24

    You can also build your own extended triggers. This will apply to both Tooltip and Popover.

    First extend the Tooltip triggers as follows:

    // define additional triggers on Tooltip and Popover
    app.config(['$tooltipProvider', function($tooltipProvider){
        $tooltipProvider.setTriggers({
            'show': 'hide'
        });
    }]);
    

    Then define the trigger on the HTML tag like this:

    And now you can call hide and show from JavaScript, this is a show in 3 seconds.

    $("#RegisterHelp").trigger('show');
    //Close the info again
    $timeout(function () {
        $("#RegisterHelp").trigger('hide');
    }, 3000);
    

提交回复
热议问题