I am struggling with the nginx config file with angularjs route.
In my case, I have these HTMLs:
index.html
description.html
dashboard.html
The dashboard.html is the one with angularjs code.
Here is my current nginx config file:
upstream panda.dev {
server 127.0.0.1:3333 max_fails=3 fail_timeout=30s;
}
server {
listen 80;
server_name panda.dev;
root /Users/Jeremy/Documents/Projects/PandaUnion/web/converted-html;
# serve static files directly
location / {
index index.html$args;
try_files $uri$args $uri$args/ $uri/ /dashboard.html$args =404;
}
}
Here is my angular code:
PandaUnion.controller('PandaController', function($routeParams, $location) {
console.log($routeParams);
});
var templateURL = '/partials';
PandaUnion.config(function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
return $routeProvider.when('/dashboard/:user_id', {
templateUrl: templateURL + '/home.html'
}).when('/dashboard/:user_id/setting', {
templateUrl: templateURL + '/setting.html'
}).when('/dashboard/:user_id/bill', {
templateUrl: templateURL + '/bill.html'
});
});
With this config, I can get dashboard.html via visiting /dashboard/123, but I can't get 123 as routeParam in angular.
It should print {user_id: 123} when I visit /dashboard/123 but I only see an empty Object.
What goes wrong here? Please help...
(sorry for my poor English)