Jan sebastian Jan sebastian - 9 months ago 26
Javascript Question

can't load index after refresh route params

I create routing for may web page like this

angular.module("ui",[]).config(function($routeProvider,$locationProvider,$httpProvider)
{
$routeProvider.when('/home',
{
templateUrl: 'home.html'

})
.when('/login',
{
templateUrl: 'login.html'

})
.when('/sign_in',
{
templateUrl: 'create_account.html'

})
.when('/profil',
{
templateUrl: 'profil.html'

})
.when('/note/:id',
{
templateUrl: 'view_note.html'

})
.when('/editNote/:id',
{
templateUrl: 'edit_note.html'

})
.otherwise({
redirectTo: '/home'
});
$locationProvider.html5Mode(true);
});


and the server side code (expressjs)

app.get('/*', function(req, res) {
res.sendFile(__dirname + '/views/index.html')
});
app.get('/note/:id', function(req, res) {
res.sendFile(__dirname + '/views/index.html')
});
app.get('/note/*', function(req, res) {
res.sendFile(__dirname + '/views/index.html')
});
app.get('/:id', function(req, res) {
res.sendFile(__dirname + '/views/index.html')
});


so all of my routing configuration run perfectly but when I try to refresh my page almost all of my page run normal except the page with
/editNote/:id
routing configuration. so how to fix this server side routing problem (expressjs)

enter image description here

Answer Source

finally I can figure out the real problem, it cause of the same name of route between mongoose route and express/angularjs route. so I change the angularjs route name