Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have been attempting to follow several different online tutorials, but keep keep failing on the same thing: getting AngularJS to load a HTML template file into the ng-view section in my page.

I have stripped it down as much as possible and am now essentially just copying this simple tutorial.

Please have a look at my test page here: http://inigowebdesign.co.uk/atest/ You should be able to see all the files there in the source code and confirm that they exist and are linked properly. Please, what am I doing wrong?

EDIT: Here is my code as it stands:

<!DOCTYPE html>
<html>
<head>
<title>Angular JS Shizzle!</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<script type="text/javascript" src="scripts/angular.min.js"></script>
<script type="text/javascript" src="scripts/angular-route.min.js"></script> 
</head>
<body>

<div class="container" ng-app="myApp">
    <header>
        <h1>Header</h1>
    </header>       
    <div ng-view></div>
    <footer>
        <h3>Footer</h3>
    </footer>
</div>

<script type="text/javascript">

angular.module('myApp', ['ngRoute']).config(function($routeProvider)){
    $routeProvider.when('/',{
        templateUrl: 'view.html'
    })
    .otherwise({redirectTo:'/something'});  
});

</script>

</body>
</html>

Thank you.

share|improve this question
    
On your test-site I get Uncaught SyntaxError: Unexpected token ) in the console log. I guess from this: config(function($routeProvider)){ –  ivarni Jun 21 at 15:43
add comment

1 Answer

up vote 0 down vote accepted

In console you have error: Uncaught SyntaxError: Unexpected token )

This ) was at the end of the first line.

Fixed:

angular.module('myApp', ['ngRoute']).config(function($routeProvider){
    $routeProvider.when('/',{
        templateUrl: 'view.html'
    })
    .otherwise({redirectTo:'/something'});  
});
share|improve this answer
    
You've got it!! Thanks! –  Inigo Jun 21 at 15:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.