Here's the files/folders in my project all in the same folder.
Github Repo for the project: https://github.com/JohnsCurry/learnAngular
Just to prove they are all in the same directory. Sorry I don't have the package.json file. The only thing to install is express. I did npm install --save express
. So I don't know why the package.json file didn't show up.
I've tried this same exact structure without a server running (Just static html and JS files client side only) and the 13.html file finds the controller13.js file just fine. When i'm running Node.js it doesn't work.
My error:
GET http://localhost:3000/controller13.js localhost/:8 angular.js:38 Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.14/$injector/modulerr?p0=mainApp&p1=Error%3…gleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.3.14%2Fangular.min.js%3A17%3A381)
So it can't find the controller13.js file for some reason, and I'm assuming that's why I'm getting the $injector
error.
13.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AngularJS | Hands On!</title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-route.js"></script>
<script src="controller13.js"></script>
</head>
<body ng-app="mainApp" ng-controller="">
<div ng-view></div>
</body>
</html>
controller13.js
var app = angular.module('mainApp', ['ngRoute']);
app.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: '/page13.html'
})
.when('/helloUser', {
templateUrl: '/hello13.html'
})
.otherwise({
redirectTo: '/'
});
});
app.js
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.sendfile(__dirname + '/13.html');
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});