1

Due to some problem I dont want to use the server but want to run the angular ngRoute truly based only on browser. However, using XAMPP or any other server it works (with external one.html and two.html), but without the server ngRoute is not able to fetch the files and show them.

<html>

<head>

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.min.js"></script> 
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular-route.min.js"></script> 

</head>

<body ng-app="myApp" ng-controller="myCtrl"> 

<a href="#/one">one</a><a href="#/two">two</a>

<ng-view></ng-view>

<script>

//app declaration
var app = angular.module("myApp",['ngRoute']);

//router
app.config(function($routeProvider){

    $routeProvider
    .when("/one", {templateUrl : "one.html"})
    .when("/two", {templateUrl : "two.html"})
    .otherwise("/one")

});

//controller
app.controller('myCtrl',function($scope){
    //code here 
});

</script> 

</body> 

</html> 

There were some questions asked long ago. I am expecting it possible at least now!

Already Seen

  1. AngularJS routing without a web server
  2. AngularJS routing without webserver?
  3. AngularJS writing an app with no server

Already Know:

I already know adding external html files to <script type="text/template> so don't add that.

halfer
  • 19,824
  • 17
  • 99
  • 186
Deadpool
  • 7,811
  • 9
  • 44
  • 88

0 Answers0