我剛剛創建了我的功能模塊和控制器,並得到了以下錯誤:
Error: [$injector:modulerr] http://errors.angularjs.org/1.4.8/ $injector/modulerr?p0=ContactsApp&p1=%5B%24injector%3Anomod%5D%
以下是我的html代碼:
<div ng-app="ContactsApp" class="container">
<div class="row" ng-controller="contactsCtrl">
<div class="col-sm-12 padding-0"> <h2 class="text-center"> Contacts</h2>
<div class="panel panel-default">
<div class="panel-heading c-list">
<span class="title">Contacts</span>
<div class="pull-right">
<a data-toggle="modal" data-target="#upload-contacts" href="#upload-contacts" data-placement="top" title="Add Contact">
<span class="title "><i class="glyphicon glyphicon-plus"></i>Add</span>
</a>
</div>
</div>
</div>
<div>
<!-- My contacts page -->
{% if contributors.details or importedContacts.details%}
{% if not role %}
{% include 'mpb/mycontacts/mycontacts_contributed_team.html' %}
{% else%}
{% include 'mpb/mycontacts/mycontacts_contributors_rolewise.html' %}
{% endif %}
{% elif not contributors.details and not importedContacts.details %}
<div class="no-contacts">
<h3 class="no-contacts-text">No Contacts to show</h3>
</div>
{% endif %}
</div>
</div>
</div>
<div id="upload-contacts" class="modal fade bs-example-modal-sm" tabindex="1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content bg-modal">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title text-center" id="mySmallModalLabel">Import your contacts <i class="glyphicon glyphicon-question-sign" rel="tooltip" title="click for help."></i></h4>
</div>
<div class="modal-body">
<!--upload your contacts-->
<div id="dvImportSegments" class="fileupload ">
<div class="btn btn-primary btn-block image-preview-input">
<span class=" glyphicon glyphicon-folder-open"></span>
<span class="image-preview-input-title">Import Contacts</span>
<input type="file" id="contactFileUpload" accept=".csv .vCard" name="File Upload"/> <!-- rename it -->
</div>
</div><!--end of upload your contacts--><br>
</div>
</div>
</div>
</div>
</div>
以下是js代碼: mycontacts.js
var app = angular.module('contactsApp', ['djangular-confirm', 'djangular-alert'])
.config(function ($httpProvider, $interpolateProvider) {
$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
$httpProvider.defaults.headers.common['X-CSRFToken'] = '{$ csrf_value $}';
$interpolateProvider.startSymbol('{$');
$interpolateProvider.endSymbol('$}');
});
app.controller('contactsCtrl', function ($scope, $http, $location, $djconfirm, $djalert) {
});
個文件我已經包括
<script type="text/javascript" src="/js/jquery-1.11.0.min.js"></script>
<script src="/js/bootstrap.js"></script>
<script type="text/javascript" src="/js/angular.min.js"></script>
<script src="/djangular/js/django-angular.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/angular-route.min.js"></script>
你有包括'mycontacts.js'文件中的index.html? – AranS
我想你忘記注入angular.module('contactsApp',[])或更改腳本文件索引。 –
[AngularJS 1.2 $ injector:modulerr]可能的重複(http://stackoverflow.com/questions/18287482/angularjs-1-2-injectormodulerr) – Simer