ng-click inside bs-tooltip not working

2019-09-17 09:00发布

I'm using angular-strap tooltip and inside I have link that should react to ng-click, but instead it's not responding.

.html

<span class="add-on input-group-addon" data-title="{{tooltips.date}}" bs-tooltip>
  <i class="glyphicon glyphicon-calendar fa fa-calendar"></i> Dates
</span>

.js

$scope.tooltips = {
  date: '<a class="btn btn-default" ng-click="select()">Select date</a>'
};

$scope.select = function() {
  //doing something and works fine outside tooltip
}

In app .config() there is html set to true.

angular.extend($tooltipProvider.defaults, {
  template: "static/lib/angular-strap/tooltip.tpl.html",
  trigger: 'click',
  html: true,
  placement: 'bottom-left'
});

1条回答
不美不萌又怎样
2楼-- · 2019-09-17 09:32

By using data-title along with html: true you are just passing some html, but it is not compiled by angular. If you want to use angular directives and data binding in your tooltip, use 'contentTemplate'; here is a working plunker: http://plnkr.co/LSl9gyHRKCMYoEGZZQei

查看更多
登录 后发表回答