Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide tooltip if empty in md-tooltip

I have following tooltip:

<i ng-click="createDetails(item)" class="fa fa-info-circle">
    <md-tooltip md-direction="top">
        {{item.details}}
    </md-tooltip>
</i>

$scope.createDetails = function (item) {
    item["details"] = "example";
}

If i click, details appears (tooltip is not centered, another problem but OK for now)

The main problem is: I want to hide the tooltip if there is no information, so when item.details == undefined

I tried ng-show, md-visible, ng-class etc. Is there a solution for these problem(s)?

like image 236
Asqan Avatar asked Mar 23 '16 10:03

Asqan


1 Answers

You can use ng-if to evaluate content of item.details variable to decide whether <md-tooltip> element is created or not.

<i ng-click="createDetails(item)" class="fa fa-info-circle">
    <md-tooltip md-direction="top" ng-if="item.details">
        {{item.details}}
    </md-tooltip>
</i>
like image 158
Naigel Avatar answered Nov 19 '22 18:11

Naigel