Skip to content

Route provider case sensitivity

jeme edited this page Apr 2, 2013 · 6 revisions

Some web servers will ignore caseing, so that http://dotjem.github.com/angular-routing/samples and http://dotjem.github.com/Angular-Routing/Samples would refer to the same thing. (e.g. IIS is known to do this by default)

Just to mirror that, the $routeProvider can turn on a case insensitive mode using the ignoreCase function.

angular.module('phonecat', []).
  config(['$routeProvider', function($routeProvider) {
  $routeProvider.
      when('/phones', {templateUrl: 'partials/phone-list.html',   controller: PhoneListCtrl}).
      when('/phones/:phoneId', {templateUrl: 'partials/phone-detail.html', controller: PhoneDetailCtrl}).
      otherwise({redirectTo: '/phones'}).
      ignoreCase();
}]);

A matchCase method also exist, this is the default state for the $routeProvider and should not be needed, but if you wish to state explicitly that you want the routes to be case-sensitive it can be used to indicate that.

ignoreCase and matchCase are global and can't be turned on for some routes and not others.

Clone this wiki locally