错误:[ng:areq]控制器未定义功能

时间:2016-05-28 14:09:08

标签: angularjs angularjs-scope

对于上述错误,我在SO和其他网站上提到了可用的解决方案,但我仍面临同样的问题。 以下是我的HTML代码:

                    <div ng-app="importContactsApp" class="modal fade" id="invitemodal" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
    <div class="modal-dialog import-contacts-dialog">
        <div  ng-controller="importCtrl" class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
            </div>
            <div class="modal-body">
                <h4 class="modal-title" id="lineModalLabel">Invite friends by email.</h4>
                <p> </p>
                <form action="" ng-submit="submit_contacts() ">
                <div class="row">
                    <div class="form-group col-sm-8 ">
                        <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
                    </div>

                    <div class="col-sm-4" >
                        <button type="submit" class="btn btn-primary btn-block">Invite</button>
                    </div>
                </div>
                <div class="row">
                   <h3 class="col-xs-12 mp_blue text-center "><hr>
                    --- OR ---<hr>
                   </h3>
                </div>
                <div id="dvImportSegments" class="fileupload ">
                    <div class="row">
                        <div class="col-sm-8 ">
                            <h4 class="modal-title">Import your contacts to invite and connect with them. </h4>
                        </div>
                        <div class="col-sm-4">
                            <div class="btn btn-primary btn-block image-preview-input marg0">
                                <span class=" glyphicon glyphicon-folder-open"></span>
                                <span class="image-preview-input-title">Import</span>
                                <!--<input ng-model="formData.file" type="file" id="contactFileUpload" accept=".csv .vCard" name="File Upload"/></input> <!-- rename it -->
                                <input type="file" ng-model="formData.file" multiple="" name="files" id="wizard-picture">
                            </div>
                            <div class="btn btn-primary btn-block image-preview-input marg0">
                                <span class=" glyphicon glyphicon-folder-open"></span>
                                <span class="image-preview-input-title">save</span>
                                <input type="submit">
                            </div>

                            <div> <a class="small" href="learn-how.html">Learn how</a>
                            </div>
                        </div>
                    </div>
                </div><!--end of upload your contacts--><br>
                </form>
            </div>
        </div>
    </div>
</div><!--end of modal-->

以下是我的角度代码: 我已将两个部分都写在同一个文件中。

    var app = angular.module('importContactsApp', []);

app.controller('importCtrl', function($scope, $http) {
    $scope.formData = {};
    $scope.name = 'World';

});

以下是我收录的文件列表:

<script type="text/javascript" src="jquery-1.11.0.min.js"></script>
<script src="bootstrap.js"></script>
<script type="text/javascript" src="angular.min.js"></script>
<script src="djangular/js/django-angular.min.js" type="text/javascript"></script>
<script type="text/javascript" src="angular-route.min.js"></script>
<script type="text/javascript" src="wizValidation/wizValidation.js"></script>
<script type="text/javascript" src="angular-cookies.js"></script>

1 个答案:

答案 0 :(得分:0)

您没有输入正确的ng-app名称,

从此模块名称

 var app = angular.module('importContactsApp', ['angular-confirm', 'angular-alert']);

更改

发件人:

   <form ng-app="myapp" ng-controller="importCtrl" action="" ng-submit="submit_contacts()">

   <form ng-app="importContactsApp" ng-controller="importCtrl" action="" ng-submit="submit_contacts()">