Tim
Tim

Reputation: 5681

Specify locale id in url

I can find very little about this specific subject of angularJS.

How can I specify and rewrite all urls with a locale id, like en-uk, nl-nl?

I also want to use proper routing to automate the process and providing the locale id to the corresponding controllers.

A few examples:

Question: How is this done in angularJS?

Upvotes: 0

Views: 537

Answers (1)

Mathew Berg
Mathew Berg

Reputation: 28750

You can configure the $routeParams to have the locale as the first section:

$routeProvider
    .when("/:local/home", { controller: "HOME_CONTROLLER" ... })
    .when("/:local/shop", { controller: "SHOP_CONTROLLER" ... })

Here's the documentation on it: http://docs.angularjs.org/api/ngRoute.$routeParams

Upvotes: 1

Related Questions