AngularJS $ location that prevents the browser from using the following hyperlinks

I have a problem with angularJS service $location. I use it to retrieve the "GET" parameters from a URL. The problem is that it disables all hyperlinks on the page (if not open on a new tab). Therefore, if you click on the link, this will change the URL, but the page will remain the same.

What can i do with this?

Angularjs v1.2.16

var myApp = angular.module('rtApp', [])
    .config(['$locationProvider', function($locationProvider) {
        $locationProvider
            .html5Mode(true);
    }])
    .service('Product', ['$http','$location',function($http, $location) {
        var url   = '/shop/product_data.php',
            query = $location.search();

        var service = $http.post(url, query).then(function (r) {
            if (r.status === 200) {
                return r.data;
            } else {
                return false;
            }
        });
        return service;
    }]);
+4
source share
1 answer

This seems to be a known issue with the angularJS service $location.

https://github.com/angular/angular.js/issues/4608

Therefore, the solution should not be used $locationif you are not using routing.

+2

Source: https://habr.com/ru/post/1539591/


All Articles