Angular $location.search() returns empty object

11 views
Skip to first unread message

Rose Hulman

unread,
Apr 20, 2018, 1:38:58 PM4/20/18
to Angular and AngularJS discussion
I believe I have everything set up correctly, but $location.search() returns "{}". I am using Angular 1.5.8

Here is my code:

var app = angular.module('newsArticleListing', ['angularUtils.directives.dirPagination', 'ui.bootstrap']);

app.controller('articleListing', ['$scope', '$http', '$location', function($scope, $http, $location){
    
// only absUrl returns something and the returned url does have several queries on it
    $scope.absUrl = $location.absUrl();
    
// returns nothing
    $scope.path = $location.pathl();

// returns nothing
    $scope.url = $location.url();
    
// returns {}
    $scope.urlQuery = $location.search();

    $http.get(jsonFeed).success(function(response){ 
        // JSON Data
$scope.articles = response.articles;
        $scope.allCategories = response.allCategories;
            
        // Pagination Initialization
        $scope.pagination = { current: 1 }; 
        $scope.pageSize = 9; 
      
// configure locationProvider  
   app.config(['$locationProvider', function($locationProvider){
       $locationProvider.html5Mode(true);
   }]);

    // Add 'site:' to list of safe urls
    app.config( [

        '$compileProvider',
        function( $compileProvider )
        {   
            $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|site):/);
        }
    ]);
       
// Reset page to 1 when search input changes
    $scope.changeHandler = function() {
        $scope.pagination = {
            current: 1
        };
    };
}]);

Reply all
Reply to author
Forward
0 new messages