0

I'm new to Angular.js so bear with me. I found Angular's routing pretty neat which is why I want to try my first Webpage with it. My approach is the following:

<!doctype html>
<html ng-app="test">
  <head>
    <meta charset="UTF-8">
    <title>testrouting</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.min.js"></script>
    <script type="text/javascript" src="js/angular-route.min.js"></script>
    <script type="text/javascript" src="js/app.js"></script>
  </head>


  <body>
    <div id="inject" ng-view></div>
  </body>
</html>

and the an app.js

var app = angular.module('test', ['ngRoute']);

app.config(function($routeProvider) { 
$routeProvider
    .when('/', {
        templateUrl: 'routes/index.html'    
    });
});

problem is, that index.html is not shown. Inside index.html I have a plain <p> element with some text. But no text is showing on my root index. As far as I know angular is a front-end framework, so is there any Webserver neccessary which causes the problem?

Thanks

3
  • 1
    yes, you have to run it from a webserver otherwise angular can't request your template due to the same-origin policy being enforced for file:// locations. Commented Aug 2, 2014 at 17:11
  • Are you saying that you have /index.html as a starting point and /route/index.html as a partial view? Commented Aug 2, 2014 at 17:21
  • just for testing, it works fine so far. Commented Aug 2, 2014 at 17:24

1 Answer 1

1

I've seen places that say that routing requires a server:

http://scotch.io/tutorials/javascript/single-page-apps-with-angularjs-routing-and-templating

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.