我想使用 Bootstrap 弹出窗口作为对话框。
<a popover href="#"
data-toggle="popover" title=""
data-html="true"
data-content=
"<p>Are you sure? {{contact.FirstName}} will be removed!</p>
<button class='btn'>Yes</button>
<button ng-click='cancel()' class='btn'>Cancel</button>"
data-original-title="Remove Contact">Remove</a>
JS:
var ang = angular.module("ang", []);
ang.controller("angCtrl", function($scope) {
$scope.contact = {
Id: 1,
FirstName: "John",
LastName: "Doe"
};
$scope.cancel = function() {
console.log('Cancel called');
};
});
ang.directive("popover", function() {
return {
restrict: "A",
link: function (scope) {
scope.$watch("contacts", function () {
$("a[data-toggle=popover]")
.popover()
.click(function (e) {
e.preventDefault();
});
});
}
};
});
问题是 bootarap 在 Angular 应用其绑定(bind)后生成 popover html。如何包含新生成的弹出窗口?
提前致谢!
最佳答案
http://mgcrea.github.io/angular-strap/#/popover 弹出指令/popover.js
获取外部 html 部分(或内联 ng-template)并用其内容填充弹出窗口。
关于twitter-bootstrap - Angular 与 Bootstrap 弹出窗口。如何在生成的弹出框主体中应用绑定(bind)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16759351/