And for the "Back" button, you will need to save the history array with past clicks / links and click "pop" from this when you click and click. A “complete” solution would look like this:
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>
app.js
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();
}
}]);
source
share