Struggling to integrate Angular with Django has been quite a challenge for me. After finally managing to make it work, I encountered yet another error. Each time I load the application, the following error message pops up:
Error: [ng:areq] Argument 'GreetingController' is not a function, got undefined
I've explored various solutions on Stack Overflow to no avail.
The snippet of my Angular code saved as app.js is as follows:
var app = angular.module('ABC',['ngRoute', 'ui.bootstrap']).
controller('GreetingController', ['$scope', function($scope) {
$scope.greeting = 'Hola!';
}]);
app.config(function($interpolateProvider, $routeProvider){
//$interpolateProvider.startSymbol('[[');
//$interpolateProvider.endSymbol(']]');
$routeProvider.when('/about', {
templateUrl: 'views/about.html'
}).when('/login',{
templateUrl: '/views/login/login.html'
}).otherwise({
redirectTo: '/about'
});
});
And here's my HTML snippet:
{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/assets/js/bower_components/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="/assets/style/main.css">
<link rel="stylesheet" href="/assets/style/container.css">
<link rel="stylesheet" href="/assets/style/button.css">
<script src="/assets/js/bower_components/jquery/dist/jquery.js"></script>
<script src="/assets/js/bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="/assets/js/bower_components/angular/angular.js"></script>
<script src="/assets/js/bower_components/angular-route/angular-route.js"></script>
<script src="/assets/js/bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="/app.js"></script>
<script src="/views/login/login.js"></script>
</head>
<body ng-app="ABC">
<div class="container-fluid">
<nav class="navbar navbar-default navbar-fixed-top navbar-inverse">
<ul class="nav navbar-nav">
<li><a href="#home">Home</a></li>
<li><a href="#login">Login</a></li>
<li><a href="#signup">Sign Up</a></li>
</ul>
</nav>
</div>
<div id="wrap" ng-controller="GreetingController">
<div class="container-fluid" id="main">
<ng-view></ng-view>
</div>
</div>
</body>
</html>
I would greatly appreciate any help in resolving this issue.
Here is the link to the source code.
Thank you in advance.