0

Does anyone know how I can route using a search query in Angular? I have tried working with $routeProvider but it doesn't work with search queries.

This is the code I wrote for routing with $routeProvider:

app.config(['$routeProvider', function ($routeProvider){
  $routeProvider.when('/?table=table1', {
  controller:'PostsCtrl',
  templateUrl: 'table1.html'
}) 
  $routeProvider.when('/?table=table2', {
    controller: 'PostsCtrl',
    templateUrl: 'table2.html' 
})
  $routeProvider.otherwise({redirectTo: '/?table=table1'});
}]);

app.config(['$locationProvider', function($locationProvider){
   $locationProvider.html5Mode(true).hashPrefix('!');
}]);

and the templates they are referring to:

<script type="text/ng-template" id="table1.html">
  some code
</script>

and

<script type="text/ng-template" id="table2.html">
  some code
</script>

0 Answers0