After implementing AngularJS in my application, I encountered an error when adding a configuration section for routing:
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.9/$injector/modulerr?p0=demoApp&p1=Error%3A…nts%2FGitHub%2FSirwanAfifi.github.io%2Fscripts%2Fangular.min.js%3A32%3A232)
Here is the code snippet causing the issue:
var demoApp = angular.module('demoApp', []);
demoApp.config(function ($routeProvider) {
$routeProvider
.when('/',
{
controller: 'CustomerController',
templateUrl: 'views/view1.html'
})
.when('/view1',
{
controller: 'CustomerController',
templateUrl: 'views/view1.html'
})
.otherwise({redirectTo:'/'});
});
I came across this answer, which suggests using angular-route.min.js
, but I prefer to keep the routing simple in my application.