javascript - MEAN Stack, Why does express keep routing with a # in the url -


trying used end stuff. started off following thinkster guide on express. wondering if clear stuff me.

firstly, understand front-end , back-end routing different. understanding front end routing user experience (going page page), , end routing (e.g router.get(~~~)) used api calls , interacting database stuff. why

router.get('/', function(req, res, next) {   res.render('index'); }); 

is whats loading first page?

secondly, front end routing looks this

app.config([ '$stateprovider', '$urlrouterprovider', function($stateprovider, $urlrouterprovider) {      $stateprovider         .state('home', {             url: '/',             templateurl: '/home.html',             controller: 'mainctrl'         })      $urlrouterprovider.otherwise('home'); } ]); 

however, whenever run server , go localhost:3000, automatically puts me localhost:3000/#/ , serves content there. know thinkster guide uses inline templates trying use seperate html files, , still doing that.

if clear confusion, id grateful! thank you

it's angular's default behaviour of routing urls.

to remove hashtag urls, need set angular's $locationprovider's html5mode true

app.config([ '$stateprovider', '$urlrouterprovider',$locationprovider,  function($stateprovider, $urlrouterprovider, $locationprovider) {      $stateprovider         .state('home', {             url: '/',             templateurl: '/home.html',             controller: 'mainctrl'         })      $urlrouterprovider.otherwise('home');      $locationprovider.html5mode(true);  } ]) 

check out article more info.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -