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

时间:2016-09-15 18:54:21

标签: javascript angularjs angular-ui-bootstrap

我打算在打开时将一些模型数据传递到模态窗口。它在$ http.post成功,也在失败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>

我得到了我的模态,我也得到了静态数据,但传递给它的数据没有反映出来。我花了一整天时间努力完成这项工作。

编辑:添加当前输出图片。Data not being passed to modal

请帮助我!

1 个答案:

答案 0 :(得分:0)

正如@charlietfl指出的那样,这是一个悬而未决的问题。要使用上述代码,请在按钮的var ModalInstanceCtrl = func.. ng-click之前移动$http