I'm having trouble resolving this issue. I've implemented other controllers in the same manner that are working fine, but this specific one is throwing an error
Error: ng:areq Bad Argument" "Argument 'myCtrl' is not a function, got undefined
. Below is my code:
//js
var myApp = angular.module('myApp', ['ngMaterial','angularUtils.directives.dirPagination']);
myApp.config(function($interpolateProvider) {
$interpolateProvider.startSymbol('<@');
$interpolateProvider.endSymbol('@>');
});
(function(){
var myContacts = angular.module('myApp');
myContacts.controller('myCtrl', function ($scope, $http) {
$scope.totalContacts = 0;
$scope.request_limit = 3;
$scope.pagination = {
current: 1
};
getContacts(1);
$scope.pageChanged = function(newPage) {
getContacts(newPage);
};
$scope.getContacts = function(pageNumber){
api_url = '/api/people/list?page=' + pageNumber;
$http.get(api_url).success(function(data){
$scope.contacts = data.data;
$scope.totalContacts = data.count
console.log('Data: '+ $scope.contacts);
if(data.code == 9999) {
displayMessage('Error', data.msg);
} else if (data.code == 8888) {
displayMessage('Error', data.msg);
} else if (data.code == 1001) {
displayMessage('Info', data.msg);
} else if (data.code == 1000) {
$scope.contacts = data.data;
hideMessage();
}
});
}
});
})();
// html
<html lang="en" ng-app="myApp">
<head>...
<div data-ng-controller="myCtrl" class="container-fluid" id="pcont">
<table class="table no-border hover">
<thead class="no-border">
<tr>
<th class="text-center"><strong>Position</strong></th>
<th class="text-center"><strong>Organization</strong></th>
</tr>
</thead>
<tbody class="no-border-y">
<tr dir-paginate="contact in contacts | itemsPerPage: request_limit" total-items="totalContacts" current-page="pagination.current">
<td class="text-center"><@ contact.contact_position @></td>
<td class="text-center"><@ contact.organization_name @></td>
</tr>
</tbody>
</table>
Can anyone spot what might be causing the error?