0

routes.js

app.route('/*')
    .get(indexController.render);

indexController.js

exports.render=function(req, res){

        res.render('index');

    }

config.js

$locationProvider.html5Mode(true);

I am trying to implement html5 mode in my mean application. This did not work. Anything wrong in this

3 Answers 3

1
exports.render=function(req, res){
    //Your path to the html with .html
    res.render('index.html');
}
Sign up to request clarification or add additional context in comments.

3 Comments

i already mentioned my views location in express configuration file
app.set('views', __dirname + '/views'); app.get('/', module.renderIndex); module.renderIndex = function(req,res){ res.render('index.html') };
To know how to do it you can check my website source code, look at the server.js and routes/routes.js ;) github.com/AugustoL/website/tree/master/website-front
1

In the index page, you should put this:

<base href="/">

to help html5mode.

1 Comment

This answer isn't clear to me; can you expand it a bit and format it?
1

To make sure that angular can handle your routes without a hash bang url (#/), you must add this code to your main index.html:

<base href="/">

This is to make sure that angular knows that this page is the main page and that routes should dynamically be populated in this page.

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.