6

I have an angular application such that the routing might look like this:

angular.module('app').config(function($routeProvider, $locationProvider) {
  $routeProvider

  .when('/', {
    templateUrl : 'views/home.html',
    controller: 'homeController'
  })
  .when('/foo', {
    templateUrl : 'views/foo.html',
    controller: 'fooController'
  })
  .otherwise({
    redirectTo : '/'
  });
  $locationProvider.html5Mode(true);
});

Now, this may be an overly simple question, but can I serve a static page that is never going to change and needs no added javascript from me without specifying it with a .when route? For example, say I want to serve Googles Webmaster tools verification like so:

/googlee23dc3443279f430.html

Do I really need to create a .when('/googlee23dc3443279f430.html') route?

EDIT: We also did a server rewrite to make it so that non '/' routes would still serve up the index.html file, as specified in this wiki (and to get html5mode(true) working on page refreshes):

https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode

Would be nice not to have to add rewriteconditions each time we want to add a static page

2
  • Why would you need a route? If the static html page exists on disk, just point your browser to the URL of that static page. Angular will have nothing to do with it Commented Nov 19, 2014 at 23:58
  • @link64 well, we're using $locationProvider.html5Mode(true) and in order to get that working with page refreshes we did a server rewrite to serve up the app when the route wasn't '/', as specified in this wiki: github.com/angular-ui/ui-router/wiki/… Commented Nov 20, 2014 at 0:05

1 Answer 1

1

if the entire page should be replaced with static html, you can use a link with ng-href (to make it dynamic and data based and not hardcoded) - https://docs.angularjs.org/api/ng/directive/ngHref

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.