【发布时间】:2015-05-30 20:46:20
【问题描述】:
我有 4 个按钮,它们调用模态引导窗口,当我这样做时,函数会使用 $scope 的变量加载 html-temptale,但是模态窗口不适用于 $scope,我之前问过这个问题并且有回答使用指令,但坦率地说我不明白它是如何工作的,这是一个例子
<div class="infBox" data-toggle="modal" data-target="#myModal" ng-click="modal('Modals/modal2', row.Name)">
<h4>BUILD</h4>
<div>
<img ng-class="{opac: row.Commit.Build.Debug == false}" src="IMG/computer-md.png">
<img ng-class="{opac: row.Commit.Build.Release == false}" src="IMG/computer-md.png">
</div>
<span class="debug">Debug</span><span>Release</span>
<span class="time">{{row.Commit.Build.Timefin}}</span>
</div>
这是 div 按钮
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>
这是模态窗口
$scope.modal = function(path, name){
$scope.ModalObj = $scope.Objects[FindNumber(name, $scope.Objects)];
$http.get(path).success(function(data) {
$scope.modalData = data;
});
};
这是一个加载temptale的函数
<h4>BUILD</h4>
<div>
<img ng-class="{opac: ModalObj.Commit.Build.Debug == false}" src="IMG/computer-md.png">
<img ng-class="{opac: ModalObj.Commit.Build.Release == false}" src="IMG/computer-md.png">
</div>
<span class="debug">Debug</span><span>Release</span>
<span class="time">{{ModalObj.Commit.Build.Timefin}}</span>
这是诱惑
【问题讨论】:
-
除了@Sumeet Gohil 的回答之外,还有一个AngularJS 模态实现(但是没有引导标记),它处理模态中单独的$scope - github.com/likeastore/ngDialog
标签: javascript angularjs twitter-bootstrap