Successfully Call history.pushState() from Angular Without Inifinite Digest?

后端 未结 4 1357
野的像风
野的像风 2021-01-17 16:46

Is there a way to call history.pushState() without angular going into an infinite digest loop?

I\'m trying to migrate my app from backend routing to fro

4条回答
  •  猫巷女王i
    2021-01-17 17:03

    Use the rewriteLinks option on the $locationProvider html5Mode object:

        pageModule.config(function($locationProvider) {
            $locationProvider.html5Mode({
                enabled: true,
                requireBase: false,
                rewriteLinks: false
            });
        });
    

    Afterwards, you should be able to use the $location service properly, such as:

        this.$location.path("/mynewpath");
    

提交回复
热议问题