This is in app.js
:
var angular = angular.module('ngApp', ['ngRoute']);
angular.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: '../templates/companies.html',
controller: 'companies'
})
.........
});
This is in companies.js
:
angular.module('ngApp').controller('companies', ['$scope', function($scope) {
.........
}]);
This is in index.html
:
<head>
<title>Basic demo</title>
<script src="angular.js"></script>
<script src="angular-route.js"></script>
<script src="js/app.js" type="text/javascript"></script>
<script src="js/Controllers/companies.js" type="text/javascript" ></script>
</head>
I keep getting this error:
Uncaught TypeError: angular.module is not a function at companies.js:1
What am I doing wrong?
You are trying to use a variable called angular. Think what causes that variable to exist. That is found in the angular.js script which must then be included first.
At the time your angular code runs, angular does not exist yet. This is an error (see your console window of Dev Tools ). Kindly use same version of Angular file and angular-route !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With