Javascript Angularjs-更改模板而不更改url

Javascript Angularjs-更改模板而不更改url,javascript,angularjs,templates,url,Javascript,Angularjs,Templates,Url,Angular和JS的新手,所以我的行话可能已经过时了 在页面的某个部分中,我希望根据用户的点击情况加载不同的模板,而不改变URL路径。我知道如何在ng view中使用$routeProvider,但这需要更改URL以加载相关模板 我还想在这个特定的部分添加一个反向链接,这样用户就可以返回一个步骤 有什么想法吗?我找不到任何类似的问题,但我可能用不正确的术语搜索。非常感谢您的帮助或建议 关于我建议使用ng include。这允许您包含来自其他位置的html代码块。然后,您可以使用ng show/

Angular和JS的新手,所以我的行话可能已经过时了

在页面的某个部分中,我希望根据用户的点击情况加载不同的模板,而不改变URL路径。我知道如何在ng view中使用$routeProvider,但这需要更改URL以加载相关模板

我还想在这个特定的部分添加一个反向链接,这样用户就可以返回一个步骤

有什么想法吗?我找不到任何类似的问题,但我可能用不正确的术语搜索。非常感谢您的帮助或建议


关于

我建议使用ng include。这允许您包含来自其他位置的html代码块。然后,您可以使用ng show/hide来显示所需的片段,或者如果您希望它不在dom中(如果不需要),则可以使用ng。对于“上一步”按钮,您必须保留一个包含过去的单击/链接的历史数组,并在单击和单击“上一步”时从中按pop。“完整”解决方案类似于:

index.html

<html ng-app="app">
...
<div ng-controller="myController">

  <button ng-click="setCurrentView('tem1')">Template 1</button>
  <button ng-click="setCurrentView('tem2')">Template 2</button>
  <button ng-click="setCurrentView('tem3')">Template 3</button>

  <div ng-include="tem1.html" ng-show="currentView==tem1"></div>
  <div ng-include="tem2.html" ng-show="currentView==tem2"></div>
  <div ng-include="tem3.html" ng-show="currentView==tem3"></div>

  <button ng-click="goBack()">Back</button>

</div>
...
</html>

你是否检查了ng include?@KalhanoToressPamuditha我没有,但这看起来是解决方案。谢谢。这真的很有帮助,如果我有更多的代表,我会投这个票。谢谢。这正是我想要的,非常感谢!
angular.module('app',[]).controller('myController',['$scope',function($scope){
  $scope.currentView='tem1';
  var history=[];

  $scope.setCurrentView=function(view){
    history.push($scope.currentView);        
    $scope.currentView=view;
  }

  $scope.goBack=function(){
    $scope.currentView=history.pop();
  }
}]);