简体   繁体   English

Angular UI模式POST

[英]Angular UI modal POST

I'm trying to load angular-ui modal but I can't find any information how to pass POST parameters to specified templateUrl url? 我正在尝试加载angular-ui模式,但我找不到任何有关如何将POST参数传递给指定templateUrl url的信息?

    var options = {
        controller: 'ModalInstance',
        backdrop: true,
        scope: $scope,
        size: ( typeof $element.data('size') != 'undefined' ) ? $element.data('size') : 'sm',
        backdropClass: backdrop,
        templateUrl: 'some url',
        data: { // needs to be replaced | this one is not working.
            media_id: 59 
        },
        resolve: {
            element: function(){
                return $element;
            }
        }
    };

    $scope.instance = $modal.open( options );

If there is no any official ways, how can I do it without get parameters? 如果没有任何官方方式,我怎么能在没有参数的情况下做到这一点?

From the documentation mentioned here angular-ui directive documentation 从这里提到的文档angular-ui指令文档

templateUrl - a path to a template representing modal's content templateUrl - 表示模态内容的模板的路径

which means it should be the url to a html file or <script type="text/ng-template"> which would be rendered as the content for modal window. 这意味着它应该是html文件的url或<script type="text/ng-template"> ,它将被渲染为模态窗口的内容。

In case you want to pass some data to this template, refer the plunker example the documentation provides. 如果您想将一些数据传递给此模板,请参阅文档提供的plunker示例。

The relevant things to be noted in this example for passing data to modal template are explained below 下面解释在此示例中要将数据传递给模态模板的相关事项

controller: 'ModalInstanceCtrl',
size: size,
 resolve: {
        items: function () {
         return $scope.items;
        }
      }

1)controller : controller property specifies the name of the controller that controls the template(html to be rendered) 2)resolve: resolve property specifies the data that has to be injected into the above controller 1)controller:controller属性指定控制模板的控制器的名称(要呈现的html)2)resolve:resolve属性指定必须注入上述控制器的数据

So in the example the ModalInstanceCtrl is the controller that is in control of the template to be rendered and items property can be injected into this controller, in other words you can pass the data to the modal window template. 因此,在示例中,ModalInstanceCtrl是控制器,它控制要渲染的模板,并且可以将items属性注入此控制器,换句话说,您可以将数据传递给模态窗口模板。

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

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