我在当前项目中使用angular-ui-bootstrap,并且我需要在网格中的每一行中打开一个弹出窗口,显示行特定信息。弹出框应该有自己的HTML模板,并且有多个字段可以绑定在HTML模板中。这是我为实现同样目的而编写的代码。我确实试图通过html模板没有运气。任何帮助表示赞赏。
HTML代码:
<div ng-app="helloAngular" ng-controller="casesCntrl">
<table class="table table-bordered">
<thead>
<tr>
<th class="">Date</th>
<th class="">Case</th>
<th class="">Severity</th>
<th class="">Status</th>
<th class="">Site</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="case in cases">
<td>{{case.casedate | date:'MM/dd/yyyy'}}</td>
<td><a ng-href="#/site/{{case.id}}">{{case.name}}</a></td>
<td ng-class="{'case-critical':case.severity==1, 'case-urgent':case.severity==2, 'case-normal':case.severity==3}" class="case-none"></td>
<td>{{case.status}}</td>
<td>{{case.sitename}} <button popover="{{case.sitename}}" popover-title="{{case.sitedescription}}" data-placement="bottom" data-trigger="focus" class="btn btn-default" popover-unsafe-html="This is a Help but please <b> focus </b> on this">V</button></td>
</tr>
</tbody>
</table>
</div>
JS代码:
function CasesController($scope) {
var casesData = [
{
"name": "Case -1",
"casedate":"2013-06-26T08:02:00-0700",
"caseid":1,
"severity": "1",
"status":"New",
"siteid":1,
"sitename":"Merchant Demo 1"
},
{
"name": "Case -2",
"casedate":"2013-01-26T08:02:00-0700",
"caseid":2,
"severity": "1",
"status":"New",
"siteid":2,
"sitename":"Merchant Demo 2"
},
{
"name": "Case -3",
"casedate":"2013-02-26T08:02:00-0700",
"caseid":3,
"severity": "1",
"status":"Accepted",
"siteid":1,
"sitename":"Merchant Demo 3"
} ,
{
"name": "Case -4",
"casedate":"2013-05-26T08:02:00-0700",
"caseid":4,
"severity": "2",
"status":"New",
"siteid":1,
"sitename":"Merchant Demo 4"
} ,
{
"name": "Case -5",
"casedate":"2013-09-26T08:02:00-0700",
"caseid":5,
"severity": "3",
"status":"New",
"siteid":1,
"sitename":"Merchant Demo 5"
} ,
{
"name": "Case -6",
"casedate":"2013-04-26T08:02:00-0700",
"caseid":6,
"severity": "1",
"status":"Sent to billing",
"siteid":1,
"sitename":"Merchant Demo 6"
},
{
"name": "Case -7",
"casedate":"2013-10-26T08:02:00-0700",
"caseid":7,
"severity": "3",
"status":"New",
"siteid":1,
"sitename":"Merchant Demo 7"
}
];
$scope.cases = casesData;
}
这是与上述代码相同的小提琴: http://jsfiddle.net/anirbankundu/YyK5s/4/
我确实通过传递popover-unsafe-html来尝试该选项,如https://github.com/angular-ui/bootstrap/pull/641
中所述答案 0 :(得分:5)
目前无法完成,请查看以下问题以获取更多详细信息: https://github.com/angular-ui/bootstrap/issues/220
你可以如何使用角度带来实现这个目标。详情请参阅:http://mgcrea.github.io/angular-strap/##popovers
答案 1 :(得分:5)
使用 popover-template 属性在角度UI bootsrap版本0.13.0中引入了为弹出窗口提供模板的功能,该属性获取用于弹出框体的模板位置。 http://angular-ui.github.io/bootstrap/#/popover
答案 2 :(得分:1)
Faisal Feroz在angular-ui上引用的开放问题已经关闭并添加到框架的0.13.0版本中,所以现在这是可能的。看看https://github.com/angular-ui/bootstrap/issues/220