Reputation: 429
I'm having trouble getting my routes configured in Angular (1.3.14). I've looked at plenty of examples like this one and this one as well as a few other answers here on SO, and as far as I can tell this is setup correctly, but when I load it in a browser, nothing loads to the screen. There are no console errors, and I've verified that Angular is running by commenting out the $locationProvider line (which adds the hash back to the url).
Code is currently:
var app = angular.module('app', [
'ngRoute'
]);
app.config([
'$routeProvider',
'$locationProvider',
function($routeProvider, $locationProvider) {
$routeProvider.
when('/', {
templateURL: 'templates/home.html',
controller: 'HomeController'
}).
otherwise({
redirectTo: '/'
});
$locationProvider.html5Mode(true);
}]);
app.controller('HomeController', function($scope) {
console.log("hi");
});
<div>
HELLO
</div>
<!DOCTYPE html>
<html ng-app="app">
<head>
<base href="/">
<link rel="stylesheet" type="text/css" href="stylesheets/style.min.css"/>
</head>
<body>
<div ng-view></div>
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="js/app.js"></script>
</body>
</html>
I have also tried varying the way I declare the app. I tried adding the ng-app tag to a div in the body, I've tried using the ng-view directive, but neither of these things change the outcome. All the linked resources do load, I can view them all in dev tools. I can also navigate directly to the template file and it loads just fine. I think I'm missing something simple, but I cannot figure out what it is.
Upvotes: 2
Views: 258