Sunday, 2 April 2017

is it possible to define case-insensitive paths in Routes ?


Yes !
  1. For single route, Set property caseInsensitiveMatch : true
  2. For all the routes, Set $routeProvider.caseInsensitiveMatch = true


EXAMPLE 1
var app = angular.module("module1", ["ngRoute"]);

app.config( function ($routeProvider) {
   $routeProvider
   .when("/home", {
      templateUrl: "templates/home.html",
      controller: "homeController",

      controllerAs: "homeCtrl"
      caseInsensitiveMatch: true
   })
   .when(
"/trainings", {
      templateUrl: "templates/trainings.html",
      controller: "trainingController
",
      controllerAs: "trainingCtrl"
    })
   .when(
"/students", {
      templateUrl: "templates/students.html",
      controller: "studentController"
      controllerAs: "studentCtrl"
    })
});



EXAMPLE 2
var app = angular.module("module1", ["ngRoute"]);

app.config( function ($routeProvider) {


   $routeProvider.caseInsensitiveMatch = true;

   $routeProvider
   .when("/home", {
      templateUrl: "templates/home.html",
      controller: "homeController",

      controllerAs: "homeCtrl"
   })
   .when(
"/trainings", {
      templateUrl: "templates/trainings.html",
      controller: "trainingController
",
      controllerAs: "trainingCtrl"
    })
   .when(
"/students", {
      templateUrl: "templates/students.html",
      controller: "studentController"
      controllerAs: "studentCtrl"
    })
});


No comments:

Post a Comment

Note: only a member of this blog may post a comment.