-1

How to handle query string like (index.php?comment=hello) in routeprovider while configuration in angularjs.

Example:

angular.module('app', ['ngRoute'])
.config(function($routeProvider, $locationProvider) {
    $locationProvider.html5Mode({
        enabled: true,
        requireBase: false
    }).hashPrefix('!');
    $routeProvider
    .when('/index.php?comment=hello',{
        redirectTo:'/index.php'
    }); 
Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

You can do something like this:

Your URL will look like:

http://www.heycodetech.com/#/viewPage/param1/param2

Here is your router file have the code:

$stateProvider.state('/viewPage/:param1/:param2', {
   templateUrl: 'partials/partial1.html',
   controller: 'MyCtrl'
});

And here is the code of controller for which you can get this value.

.controller('MyCtrl', ['$scope','$routeParams', function($scope,$stateParams, $state) {
var param1 = $state.param1;
var param1 = $state.param2;
}]);

For more look here.

Pritam Banerjee
  • 17,953
  • 10
  • 93
  • 108