Angularjs 为什么在使用ng include时pushState会中断?

Angularjs 为什么在使用ng include时pushState会中断?,angularjs,pushstate,angularjs-ng-include,Angularjs,Pushstate,Angularjs Ng Include,使用ng include时,pushState功能中断 下面是一个简单的例子 <div ng-app="angularApp" ng-controller="angularCtrl"> <div ng-include="templateUrl"></div> <button ng-click="bye()">BYE</button> </div> 我们希望在按下BYE按钮后使用ng include更改正文值

使用
ng include
时,
pushState
功能中断

下面是一个简单的例子

<div ng-app="angularApp" ng-controller="angularCtrl">
    <div ng-include="templateUrl"></div>
    <button ng-click="bye()">BYE</button>
</div>
我们希望在按下
BYE
按钮后使用
ng include
更改正文值,并通过
pushState
更改页面地址。 这个例子是一个更大的项目的一部分,这个项目在这里被尽可能简化


注意:根据评论,url由pushState更改,但会立即返回其值。它在ng include过程中被忽略。

在AngularJS中更改浏览器位置本身就很棘手。最好尽可能多地使用
$location
服务,因为这可以更好地理解
$scope
摘要机制并与之配合使用

尝试在应用程序中使用以下内容:

let app=angular.module('angularApp',[]);
app.config(函数($locationProvider){
$locationProvider.html5Mode(true);
});
app.controller('angularCtrl',函数($scope,$timeout,$location){
$scope.templateUrl='/assets/hi.html';
$scope.bye=函数(){
$scope.templateUrl='/assets/bye.html';
$location.url('/finish.html');
};
});
请注意,您需要为html5模式支持提供
base[href]


...
缓冲酵母抽取物

如何获得专业人士的帮助?不幸的是,没有人回答这个问题,我需要一个答案(您能确切地说明您期望(或希望)发生什么吗?在这种情况下,中断是什么意思?以及“pushState…立即返回其值”是什么意思?除了更改外观之外,我还想更改
url
地址
(pushState)
(包括)。
URL
已正确更改。但外观更改后,
URL
将返回到以前的值。假设:我在“/about us”页面上。单击按钮后,我想将地址更改为“/contact us”。使用ng include也将更改外观。
let app = angular.module('angularApp', []);
app.controller('angularCtrl', async function ($scope) {
    $scope.templateUrl = '/assets/hi.html';
    $scope.bye = function () {
        $scope.templateUrl = '/assets/bye.html';
        history.pushState({},'','/finish.html')
    };
});