Serve static html file in angular app

I have an angular application, so 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 too simple a question, but can I serve a static page that will never change and does not need added javascript from me without specifying it with a route? For example, let's say I want Google Joomles tools to be tested like this:

/googlee23dc3443279f430.html

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

EDIT: We also rewrote the server to make it so that the non '/' routes would still display the index.html file as indicated on this wiki (and to get html5mode (true) working on page updates):

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

It would be nice not to add rewriteconditions every time we want to add a static page

+6
source share
1 answer

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

+1
source

Source: https://habr.com/ru/post/978425/


All Articles