jquery - 在 angularjs 中使用 $http 加载模态

标签 jquery angularjs modal-dialog angularjs-scope angular-ui-bootstrap

我想在 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/

相关文章:

jquery - 图像映射 : show different images on hover

javascript - 将 jquery + Bootstrap modal-dialog div 更改为 BootStrap + angularjs

html - 如果类别名称太长,我想换行

html - 如何使用 ng-repeat 打印字母编号

php - 将用户名/密码传递给服务器 url

javascript - 如果选中复选框,则将 css 应用于 href

javascript - 防止表单错误数据和显示错误div

javascript - jQuery 没有生成任何输出

javascript - 弹出模式时删除背景

javascript - window.location.replace() 不适用于表单