Routing with Angular and Node
I am learning Node and Angular. As part of my learning, I'm currently
attempting to setup a basic app that has three pages. In an effort to do
this, I've relied on the documentation available at: enter link
description here.
My project is currently structured as follows though:
/app
/views
page1.html
page2.html
page3.html
/resources
/javascript
angular-1.0.7.min.js
controllers.js
index.html
My code in index.html is straightforward. It looks like this:
<!doctype html>
<html ng-app="ngView">
<head>
<title></title>
<script type="text/javascript"
src="/resources/javascript/angular-1.0.7.min.js"></script>
<script type="text/javascript"
src="/resources/javascript/controllers.js"></script>
</head>
<body>
<div ng-controller="Index">
<a href="page1">Page 1</a>
<a href="page2">Page 2</a>
<a href="page3">Page 3</a>
<div ng-view></div>
</div>
<script type="text/javascript">
angular.module('ngView', [], function ($routeProvider,
$locationProvider) {
$routeProvider.
when('/page1', { templateUrl: 'app/views/page1.html',
controller: Page1Controller }).
when('/page2', { templateUrl: 'app/views/page2.html',
controller: Page2Controller }).
when('/page3', { templateUrl: 'app/views/page3.html',
controller: Page3Controller }).
otherwise({ redirectTo: 'app/views/page1' });
$locationProvider.html5Mode(true);
});
</script>
</body>
</html>
For some reason, my views are not appearing like they do in the example.
What did I setup incorrectly?
No comments:
Post a Comment