$location.search() not working on some base url. Links in page breaks

44 views
Skip to first unread message

Joshua Aroke

unread,
Dec 6, 2017, 10:55:27 AM12/6/17
to Angular and AngularJS discussion

So I have an angular page at **localhost:8080/quote-and-book** whom I specify a base  href url like 


    <base href="/">


or like this


    <base href="/quote-and-book">


but these cause every link in the page to freeze and refuse to route to another page even though the browser address location is changed.


However if I specify like this 


    <base href="/quote-and-book"

the link will be working but location provider will start having issue as $location.search() will be empty(undefined). In my angular code I have these configurations



    function Ctrl(service, $location) {

        var ctrl = this

        var s = $location.search()

        ctrl.isDomestic = s.isDom ? JSON.parse(s.isDom) : true


        ...

    }


    app = angular.module("app", ['ngAnimate', 'menubar', 'angular.chosen'])

    app.controller("Ctrl", ['service', '$location', Ctrl])

    app.config(['$locationProvider', function ($locationProvider) {

        $locationProvider.html5Mode(true);

    }]);


Please do help figure out what I may not be doing correctly and how to fix this such that location provider will provide data of url using $location.search() and <a>links in the page will go to specify href location on click.

Reply all
Reply to author
Forward
0 new messages