来自Angular UI bootstrap模式弹出窗口的访问控制器方法

时间:2013-12-13 04:47:04

标签: angularjs angularjs-scope angular-ui-bootstrap

我正在使用AngularUI bootstrap模式弹出窗口。我正在使用'iframe'将一个aspx文件加载到弹出窗口中。这是我的弹出模板的代码:

<script type="text/ng-template" id="uploadPopup">
    <div class="modal-header text-center">
        <h4>Upload file</h4>
    </div>
    <div class="modal-body">
       <div id='uploadProcessIndicator' class='statusInd nwAbsPos' ></div>
       <iFrame scroll="" frameborder=0 ng-src="Upload.aspx" class='uploadIFrame'>
       </iFrame>
    </div>
</script>

我的控制器作用域中有一个方法'chkAttachmentExtension(fileName)',我试图在aspx文件中调用它。这是aspx文件的代码:

<head runat="server">
<title></title>
<script src="js/ext/jquery.js" type="text/javascript"></script>

<script language="javascript" type="text/javascript">
    function enable() {
        if (document.getElementById('AuthenticateMsg').checked == true) {
            var filepath = $("#SelectFile").val();
            var result = chkAttachmentExtension(filepath);
            if (result == true) {
                document.getElementById('btnUploadFile').disabled = false;
                $(".fileUploadButton").addClass('button1');
            }
            else if (filepath == "") {
                document.getElementById('AuthenticateMsg').checked = false;
                document.getElementById('UploadMessage').innerText = 
                                            "You have not uploaded any file.";
                $("#UploadMessage").addClass('messageColor');
            }
            else {
                document.getElementById('AuthenticateMsg').checked = false;
                document.getElementById('UploadMessage').innerText = 
                           "File format not supported.The supported files 
                            are: doc,docx,gif,htm,html,jpeg,jpg,mhtml,mpp
                            ,msg,pdf,png,ppt,pptx,psd,sql,txt
                            ,vsd,xls,xlsx,xml,zip.";
                $("#UploadMessage").addClass('messageColor');
            }
        }
        else if (document.getElementById('AuthenticateMsg').checked == false) {
            document.getElementById('btnUploadFile').disabled = true;
            $(".fileUploadButton").removeClass('button1');
        }

    }
    function clearText() {
        if (document.getElementById('UploadMessage').innerText.length > 0) {
            document.getElementById('UploadMessage').innerText = "";
            document.getElementById('btnUploadFile').disabled = true;
            $(".fileUploadButton").removeClass('button1');
            document.getElementById('AuthenticateMsg').checked = false;
        }
        else {
            document.getElementById('btnUploadFile').disabled = true;
            $(".fileUploadButton").removeClass('button1');
            document.getElementById('AuthenticateMsg').checked = false;
        }

    }
    function showLoadingMssg() {
        document.getElementById('UploadMessage').innerText = "Uploading...";
        $("#UploadMessage").addClass('messageColor');
        document.getElementById('btnHiddenUploadFile').click();
    }


    // ]]>
</script>

我无法访问此方法并收到错误“chkAttachmentExtension is undefined”。我尝试将controller.js包含在aspx文件中,但它再次抛出错误,因为我认为它已经包含在我的主页html文件中。

我该如何解决这个问题?

更新: iframe父级的内容:

图片链接: http://uditnarayan.net/wp-content/uploads/2013/12/iframeParent.jpg

1 个答案:

答案 0 :(得分:0)

范围附加到dom元素,因此如果您可以访问模态的根元素,则可以在其上调用angular.element(node).scope()。范围对象应该具有您需要的方法。