1
我想在彈出窗口中顯示可點擊的表格,並在點擊某行時調用函數。我的HTML看起來像這樣:ng-click在引導彈出窗口內容中不起作用
<a popover id="showDays"
type="button"
class="btn btn-success btn-xs pull-left"
data-toggle="popover"
data-placement="right"
data-html="true"
title="Popover title"
data-content=
'<table class="table table-condensed">
<tbody>
<tr ng-repeat="d in days" ng-click="show(111)">
<td ng-bind="d"></td>
<td ng-bind="x"></td>
</tr>
</tbody>
</table>'>
<i class="fa fa-clock-o fa-lg">Click me</i>
</a>
而且我的script.js: VAR應用= angular.module( 'plunker',[]);
app.controller('MainCtrl', function($scope) {
$scope.days = [
'Sunday',
'Monday',
];
$scope.show = function(x) {
console.log("show called with " + x);
$scope.x = x;
}
}).directive('popover', function($compile, $timeout){
return {
restrict: 'A',
link:function(scope, el, attrs){
var content = attrs.content;
var elm = angular.element('<div />');
elm.append(attrs.content);
$compile(elm)(scope);
$timeout(function() {
el.removeAttr('popover').attr('data-content',elm.html());
el.popover();
});
}
}
});
的代碼是從這個question複製,答案本身工作正常,但我show
功能不被調用。任何想法爲什麼?
標記爲「爲什麼此代碼無法正常工作」 –
@AlexandreMartin,這是什麼意思?我該怎麼問這個問題? – swang
沒有使用'ui-bootstrap'的'popover'元素 –