0

We have a single page application, which we would like to share in a zip file; so it has to run standalone without a server.

Normally we build our app with grunt, call the server with "localhost:8080" and we are in our home page.

We currently don't have many routes, so our route definition looks like:

.config(['$routeProvider', function ($routeProvider) {
  $routeProvider
    .when('/',
      {
        template: function(params) {
          return !params.link ? '<data-frame></data-frame>' : '<data-seo></data-seo>';
        },
        reloadOnSearch: false
      })
    .otherwise(
      { templateUrl: 'templates/404.html', reloadOnSearch: false }
    );
}])

Html5Mode is on (in case if related):

.config(['$locationProvider', function ($locationProvider) {
  $locationProvider.html5Mode({
    enabled: true,
    requireBase: true
  });
}])

So the problem: when we run the task "grunt serve:dist" we build the app in dist directory, the generated files look also good (index.html, main.js & vendor.js etc.). All our html templates are included in main.js. But when we call the index.html (im Browser "file:///C:/ourApp/dist/local/index.html"), we just see our 404 page (our fallback route definition). So Angular has difficulties finding the route "/". What can be the reason?

Edit: When we install any web server (it does not necessarily be grunt) and copy the files in it, single page app works.. But is there any other way to make it work without any webserver?

akcasoy
  • 6,497
  • 13
  • 56
  • 100
  • 1
    Possible duplicate of [Can't open Angular app using file protocol in Chrome](http://stackoverflow.com/questions/23536450/cant-open-angular-app-using-file-protocol-in-chrome) – XCS Apr 10 '17 at 12:40
  • our problem is browser independent and we don't see any error in the console. – akcasoy Apr 10 '17 at 12:46

0 Answers0