Hi I have a form in which I am sending a searched term and category id . It works fine as I am sending both things but if a user does not enter any thing only 'category id' goes, and in back end if searched term is empty all results are display to user. 
But if I send an empty string in route params I redirect to myindex page. This is my app.js code.
  when('/subcategory/:subcatId/:search', {
                templateUrl: 'partials/subcategory.html',
                controller: 'SubCategoriesController'
            }).
My form
   <form name="searchCategoryForm">
                <div class="col-md-9 col-xs-10 col-sm-10">
                    <input class="form-control" placeholder="Find your item here...." ng-model="search" type="text" style="color:#09669c;">
                </div>
                <div class="col-md-2 col-xs-2 col-sm-2">
                    <a class="btn btn-primary" role="button" href='#/subcategory/{{cats[clicked_category].id}}/{{search}}'> Search</a>                  
                </div>
            </form>
My controller.js
$scope.search_term = $routeParams.search;
    $scope.category_id = $routeParams.subcatId;
    /* Search category form */
    $scope.search_category = function () {
        $http({
            method: 'GET',
            url: 'abc',
            params: {"name": $scope.search_term, "category_id": $scope.category_id},
            headers: {'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': $rootScope.keyword_auth_token}
        })
                .success(function (data) {
                    $scope.search_category_result = data.items;
                    console.log($scope.search_category_result);
                    })
                .error(function (data) {
                    console.log(data);
                });
    };
    /* Search category form ends here*/
    if ($scope.search_term && $scope.category_id)
    {
        $scope.search_category();
    }
 
     
    