Angular-ui modal, sending data into modal controller from $http

前端 未结 1 730
情深已故
情深已故 2020-12-24 03:06

I\'m using the angular-ui modal directive http://angular-ui.github.io/bootstrap/ .

I have followed the example from the link above.

This is my data I want to

相关标签:
1条回答
  • 2020-12-24 03:41

    You can try something like

    $scope.open = function () {
      var modalInstance = $modal.open({
        controller: 'ModalInstanceCtrl',
        templateUrl: 'productDetail.html',
        resolve: {
          items: function () {
            return ProductsFactory.getOneProduct();
          }
        }
      });
    };
    

    Basically your $modal can take a promise, so why not use it. Now the object should be available on the controller when the promise gets resolved. The ModalInstanceCtrl should be

    var ModalInstanceCtrl = function ($scope, $modalInstance, items) {
    

    since you are resolving the items property not the selectedProduct property.

    0 讨论(0)
提交回复
热议问题