I'm trying to create a simple todo list app in Angular.js and am having difficulties getting routing and ng-view to work properly. I've been working primarily through examples of code written by Dan Wahlin Modules, Routes and Factories
Right now, when I run this code, I know that Angular has been started properly and functions but ng-view doesn't seem to know what my routes.js file is telling it to display, (my two partial files are just random text so I'll know when ng-view worked properly...). I think I have everything properly coded in my routes.js but can't quite figure out why ng-view still doesn't get processed by Angular. Can someone explain to me why ng-view is being ignored in my code?
Currently, here are the files I have:
index.html
<!doctype html>
<html lang="en" ng-app="todoApp">
<head>
<link rel="stylesheet" type="text/css" src="css/app.css">
<title>Todo App</title>
</head>
<body>
<div ng-view></div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"> </script>
<script src="js/routes.js"></script>
<script src="js/controllers.js"></script>
</body>
controller.js
var todoApp = angular.module('todoApp');
todoApp.controller('UsersCtrl', function($scope) {
$scope.users = [];
});
todoApp.controller('TodoCtrl', function($scope) {
$scope.todos = [];
});
routes.js
var todoApp = angular.module('todoApp', []);
todoApp.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/users', {templateURL: 'partials/users.html', controller: 'UsersCtrl'});
$routeProvider.when('/todos', {templateURL: 'partials/todos.html', controller: 'TodoCtrl' });
$routeProvider.otherwise({ redirectTo: '/users' });
}]);