Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/142.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 解析在angular ui模式下不起作用_Javascript_Angularjs_Twitter Bootstrap_Angular Ui Bootstrap_Bootstrap Modal - Fatal编程技术网

Javascript 解析在angular ui模式下不起作用

Javascript 解析在angular ui模式下不起作用,javascript,angularjs,twitter-bootstrap,angular-ui-bootstrap,bootstrap-modal,Javascript,Angularjs,Twitter Bootstrap,Angular Ui Bootstrap,Bootstrap Modal,我试图显示一个模式使用角度引导用户界面解析控制器中的项目。问题是我无法在模态控制器中获得已解决的项 $scope.showItemsInBill = function(bill){ var modalInstance = $uibModal.open({ animation: $scope.anismationsEnabled, resolve: { items: function(){ var items = []; Billin

我试图显示一个模式使用角度引导用户界面解析控制器中的项目。问题是我无法在模态控制器中获得已解决的项

$scope.showItemsInBill = function(bill){
  var modalInstance = $uibModal.open({
    animation: $scope.anismationsEnabled,
    resolve: {
      items: function(){
        var items = [];
        BillingService.getItemsInBill(bill).then(function(response){
          console.log(response);
          return response;
        });
      }
    },
    templateUrl: 'templates/showitems-modal.html',
    controller: 'ShowItemsModalCtrl',
    backdrop: 'static'
  });
}
模态控制器如下所示:

angular.controller('ShowItemsModalCtrl', ['$scope', '$uibModalInstance', 'BillingService', 'items', function ($scope, $uibModalInstance, BillingService, items) {

init();

function init(){
  console.log('Modal is initializing');
  console.log(items);
  $scope.items = items;
}

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

$scope.printBill = function(){
  console.log('printing bill');
}
}]))

我在控制台中得到的响应是:

history controller.js:24[Object]0:Objectlength:1__proto__;u:Array[0]

showitems模态控制器.js:8模态正在初始化

showitems modal controller.js:9未定义

因此,我从这里了解到,调用了来自服务的成功回调,但没有解析为模态控制器,而是初始化了模态控制器。为什么会这样


是因为我从成功回调返回响应。如果是,在这种情况下我能做什么?

您需要在解决方案中返回承诺

resolve: {
  items: function(){
    var items = [];
    // missing "return"
    return   BillingService.getItemsInBill(bill).then(function(response){
      console.log(response);
      return response;
    });
  }
},

你需要在决议中回报承诺

resolve: {
  items: function(){
    var items = [];
    // missing "return"
    return   BillingService.getItemsInBill(bill).then(function(response){
      console.log(response);
      return response;
    });
  }
},

我的成功回调中的返回是什么?它的作用是什么?返回值以便下一个
可以访问它。您看不到next
then
,但它在内部用于在controller中创建注入参数,在我的成功回调中返回什么?它的作用是什么?返回值以便下一个
可以访问它。您看不到next
then
,但它在内部用于在控制器中创建注入参数