繁体   English   中英

Angular-ui-bootstrap模式不显示传递给它的数据

[英]Angular-ui-bootstrap modal not showing data passed to it

我正在尝试将一些模型数据打开时传递给模式窗口。 它在$ http.post成功中失败, then()then()中失败, then()带有一些不同的标题和按钮文本。 我像这样传递多个数据:

//.then(){...//same as below }
,function (response){
     $scope.PostRespData = response.data.message || 'Rq Failed';

     $scope.pn = $scope.PostRespData.substring(53,63);

     //(status=400) response modal string
     $scope.name = 'Hey there!';

     //modal options
     $scope.opts = {
                backdrop: true,
                backdropClick: true,
                dialogFade: false,
                keyboard: true,
                templateUrl : 'alreadyexists.html',
                controller : ModalInstanceCtrl,
                resolve: {}
                };


    $scope.opts.resolve.item = function() {
                   return angular.copy({name:$scope.name, errmsg:$scope.PostRespData, num:$scope.pn}); // pass name to modal dialo
                        }

     //open the modal and create a modal Isntance
     var modalInstance = $uibModal.open($scope.opts);

     var ModalInstanceCtrl = function($scope, $uibModalInstance, $uibModal, item) {

          $scope.item = item;

          $scope.ok = function () {
          $uibModalInstance.close();

          };

          $scope.cancel = function () {
          $uibModalInstance.close();
                        }

我的HTML模板看起来像

<div class="modal-header">
  <h1>{{item.name}}</h1>
</div>
<div ng-controller="Nav" class="modal-body">
<p>{{item.errmsg}}
    <a href="http://myserver.com/page.jsp?num="+{{item.num}}+"&c=y">View {{item.num}}</a>
</p>
</div>
<div class="modal-footer">
  <button class="btn btn-primary" ng-click="ok()">Edit Current Details</button>
<button class="btn btn-warning" ng-click="cancel()">Edit {{item.num}}</button>
</div>

我得到模态,也得到静态数据,但是传递给它的数据不能反映出来。 我整天都在努力使这项工作。

编辑:添加当前输出图片。 数据未传递到模态

请帮我!

正如@charlietfl指出的那样,这是一个悬而未决的问题。 要使用上面的代码,请将var ModalInstanceCtrl = func..移动到按钮的$httpng-click调用之外。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM