我这里有这个模态
<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">Details</h4>
</div>
<div class="modal-body">
<div class="row" ng-repeat="prods in products">
<div class="col-sm-4">
<p>@{{prods.pd }}</p>
</div>
<div class="col-sm-4">
<p>@{{ prods.quantity }}</p>
</div>
<div class="col-sm-4">
<p>@{{ prods.totalline }}</p>
</div>
</div>
</div>
</div>
</div>
</div>
我在按钮中显示我的模型
<button id="btn-add" class="btn btn-primary btn-sm" ng-click="toggle()"> View Details <i class="fa fa-plus" aria-hidden="true" style="margin-left: 50px; margin-right: 20px"></i></button>
我试图显示一些数据。 我的控制器js是这样的
app.controller('productDelivedController', function($scope, $http, API_URL) {
$scope.toggle = function() {
$http.get(API_URL + 'donation/listLines/1')
.success(function(response) {
$scope.products = response;
});
$('#myModal').modal('show');
}});
可能我做错了什么,但我不知道是什么,我正确地接收数据,就像我正在接受但我不能用这些数据更新我的模态。
答案 0 :(得分:0)
请在成功功能中尝试模态显示代码,在加载数据之前显示对话框。
如果在加载数据后显示模态,则问题不会发生。
app.controller('productDelivedController', function($scope, $http, API_URL) {
$scope.toggle = function() {
$http.get(API_URL + 'donation/listLines/1')
.success(function(response) {
$scope.products = response;
$('#myModal').modal('show');
});
}});