我想在 angularJs 的帮助下在模态(ui.bootstrap.modal)中加载数据。例如,我通过 post 方法发送请求并成功检索数据,现在我想将其加载到模态中。这是我的代码
var MainAdmin = angular.module('MainAdmin', ['ui.bootstrap']);
function MainAdminController($scope, $http, $modal) {
$scope.LoadTypesView = function() {
$http({
method : 'POST',
url : 'load.php',
data : dataArray,
headers : { 'Content-Type': 'application/json' }
})
.success(function(data) {
if(data.result.status=="success")
{
$scope.Type = data.result.response; // Type is an array which is defined.
$modal.open({
templateUrl: 'UserTypeModal.html',
backdrop: true,
windowClass: 'modal',
controller: function ($scope, $modalInstance, $log, Type) {
$scope.SubmitUserType = function () {
$modalInstance.dismiss('cancel');
}
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}
});
}
});
};
}
这是我的 HTML
<h1><a href="" ng-click="LoadTypesView()">Types</a></h1>
<script type="text/ng-template" id="UserTypeModal.html">
<div class="modal-header">
<h3>Define User Rights</h3>
</div>
<form ng-submit="SubmitUserType()">
<div class="modal-body">
</div>
</form>
<div class="modal-footer">
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>
</script>
请提供一些示例代码 提前致谢
最佳答案
试试这个方法。这就像一个简单的示例
<div ng-repeat="inventory in Type ">
<p>{{inventory.YourField}}</p>
</div>
关于jquery - 在 angularjs 中使用 $http 加载模态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22089397/