Inject a dependency for the Notes
module/controller that we’ll soon create, and update the catch-all route:
app/app.js
angular.module('meganote', [
...
'meganote.version',
'meganote.notes'
...
$routeProvider.otherwise({redirectTo: '/notes'});
...
Make a new directory for our new module, app/notes
, and add a file named notes.js
under it:
app/notes/notes.js
'use strict';
angular.module('meganote.notes', ['ngRoute'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/notes', {
templateUrl: 'notes/notes.html',
controller: 'NotesController'
});
}])
.controller('NotesController', [function() {
}]);
Add a file app/notes/notes.html
:
app/notes/notes.html
Welcome to Meganote.
Specifying the dependencies to AngularJS is not sufficient to actually get those scripts sent to browsers. We must require the notes controller in index.html
:
app/index.html
<script src="notes/notes.js"></script>
Now, if you visit the root url (http://localhost:8000/), you should be taken to /notes
and see the welcome message from app/notes/notes.html
.
Commit.