Hi,
I have a following AngularJS app:
angular.module('app', ['ngRoute', 'app.controllers']).config(['$routeProvider',
function($routeProvider){
$routeProvider
.when('/', {
controller: 'HomeController',
templateUrl: 'views/home.html'
})
.when('/garage', {
controller: 'GarageController',
templateUrl: 'views/vehicle.html'
})
.otherwise({
redirectTo: '/'
});}]).config(['$locationProvider', function($locationProvider) {
$locationProvider.html5Mode(true);}]);
Node.js is my backend and its only purpose is to provide REST api (which is
not implemented yet). Express configuration is as follows:
app.use(express.static(path.join(__dirname, 'public')));
app.get('*', function(req, res) {
res.sendFile(__dirname + '/public/index.html');});
The problem is that whenever I put some invalid url in the address bar, like
http://localhost:3000/abc request reaches the server. I assumed, that it
should be handled by AngularJS routing and redirected to default '/' page.
Why is that not happening? When that happens, all aplication is downloaded
once again, all index and assets files. I would like to tell AngularJS -
whenever somebody enters an invalid route, just route to the default one.
And this should just replace ng-view, rather than downloading whole
index.html once again. Is that possible?
Thanks
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.