Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update angular-ui (bootstrap) popover content dynamically

I'm trying to change popover's content dynamically binding 'uib-popover-title' with 'dacc.getSearchResultHTML()' function, but updating 'dacc.codeJerarchy.parent' object just changes popover's title.

I'm missing something or do i need to redefine the HTML element? Its the only way i achieved to update the content for the moment.

Thanks!

<button uib-popover-html="'{{ dacc.getSearchResultHTML(dacc.codeJerarchy.parent) }}'"
popover-title="{{ dacc.codeJerarchy.parent.short }}"
popover-placement="right"
popover-append-to-body="true" type="button"
class="btn btn-sm btn-default">i</button>

//-------------------------------------------

dacc.getSearchResultHTML = function(searchResult) {
    return $sce.trustAsHtml(he.encode(he.escape(searchResult.long)).replace(/\n/g, '<br />'));
};
like image 222
sr.u Avatar asked Jan 20 '26 05:01

sr.u


1 Answers

uib-popover-html takes an angular expression, it's unnecessary to wrap your function call with double curly braces. Instead, pass in a variable/function on the $scope object.

HTML

<button type="button" class="btn btn-sm btn-default"
    uib-popover-html="dacc.getSearchResultHTML(dacc.codeJerarchy.parent)"
    popover-title="{{ dacc.codeJerarchy.parent.short }}"
    popover-placement="right"
    popover-append-to-body="true"        
    >
    i
</button>

Controller

$scope.dacc = {
    getSearchResultHTML: function(input) {
        ...
        return output;
    }
}
like image 76
tylerwal Avatar answered Jan 22 '26 17:01

tylerwal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!