1
내 popover에서 클릭 가능한 테이블을 표시하고 행 중 하나가 클릭 될 때 함수를 호출하려고합니다. 내 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' 엘리먼트를 사용하지 않았습니까 –