Reputation: 7547
For example if I have this kind of url localhost/About
, localhost/Projects
, localhost/Photography
, how can I get the value after localhost/
, i.e About
Projects
Photography
?
I have written my app.js as below:
angularSite.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/About', {
templateUrl: 'partials/about.html',
// controller: 'AboutController'
}).
when('/Projects', {
templateUrl: 'partials/projects.html',
controller: 'WorkController'
}).
when('/Photography', {
templateUrl: 'partials/photo.html',
}).
otherwise({
redirectTo: '/'
});
}]);
Upvotes: 0
Views: 457
Reputation: 39522
If you need to get the current path in a controller/service/directive, $location.path()
should do it (you'll need to inject $location
).
Upvotes: 1