Search code examples
angularjspopoverangular-strap

Dynamic path for data-template in angular-strap bs-popover directive


I have used the angular-strap 'bs-popover' directive to open a popover using a custom html template. Following is the code sample which calls the directive when an input field is clicked.

<div ng-controller="ctrl"> <input size="6" type="text" ng-model="cell.HHmm__c" data-template= "/projectA/v/d/views/popoverTemplate.html" data-animation="am-flip-x" bs-popover="popover"></input> </div>

Everything is working fine. However, now I want to set the data-template using a string variable in my controller. As an example, assume I have a variable

$scope.templatePath = "/projectA/v/d/views/popoverTemplate.html"

in my controller ctrl. If so, how do I assign the variable templatePath as the data-template path in my bs-popover directive?


Solution

  • You can have two way to do this

    ng-attr-data-template="{{templatePath}}"
    

    OR

    data-template="{{templatePath}}"
    

    Hope this could help you, Thanks.