Javascript 引导模式应该选择从json获得的表行(角度)
我有一个表,使用ng repeat填充数据,这是从JSON获得的 表中有名称、电话和时间 当我点击名称时,会弹出一个引导模式,但我需要在引导模式中选择名称Javascript 引导模式应该选择从json获得的表行(角度),javascript,angularjs,json,twitter-bootstrap,Javascript,Angularjs,Json,Twitter Bootstrap,我有一个表,使用ng repeat填充数据,这是从JSON获得的 表中有名称、电话和时间 当我点击名称时,会弹出一个引导模式,但我需要在引导模式中选择名称 <tbody> <tr ng-repeat='row in rows'> <td data-toggle="modal" data-target="#myModal" ng-modal="" > <a>{{row.name}}</a&
<tbody>
<tr ng-repeat='row in rows'>
<td data-toggle="modal" data-target="#myModal" ng-modal="" > <a>{{row.name}}</a></td>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">{{row.name}} Details</h4>
</div>
</div>
</div>
<td>{{ row.phone}}</td>
<td>{{row.time}} </td>
</tr>
</tbody>
我希望表的单击名称位于模式标题上
感谢您的帮助。提前感谢添加一个ng click处理程序,将名称设置为范围属性。然后使用此属性作为模态标题的标题
在生成表的HTML中:
ng-click="setName(row.name)"
在控制器中:
$scope.selectedName=null
$scope.setName = function(name) {
$scope.selectedName = name;
}
然后,您可以将其用于模式标题
{{selectedName}}
最简单的方法是在控制器中添加一个函数,将名称设置为当前范围变量,然后在标题中显示该变量。
请查找修改后的plunker的链接
script.js:
$scope.getName = function(name) {
$scope.fName = name;}
home.html
<h4 class="modal-title" id="myModalLabel">{{fName}}</h4>
{{fName}
希望有帮助。谢谢您的回复。你能在plunker中实现它吗。这真的很有帮助