If you plan on the main website from one page through pushState, you may need an intimate understanding of $ routeProvider ( http://docs.angularjs.org/api/ngRoute.%24routeProvider ).
To move further along the rabbit hole, I would recommend looking at the ui-router module: ( https://github.com/angular-ui/ui-router ). $ stateProvider (from ui-router) and $ routeProvider work very similarly, so sometimes ui-router documents can give information that you cannot find in poor $ routeProvider documentation.
I recommend reading the five-page ui-router documentation ( https://github.com/angular-ui/ui-router/wiki ) per page.
After all this preamble, itβs practical here: you would create a factory that stores history data and uses the controller defined in your $ routeProvider / $ stateProvider to access and manage this data.
Note. factory is a service. A service is not always a factory. Namespace:
angular.module.<servicetype[factory|provider|service]>.
This post describes the types of services: fooobar.com/questions/203 / .... It is important to remember that they are all solitary.
Example:
var myApp = angular.module("myApp",[]); myApp.factory("Name", function(){ return factoryObject });
The code looks something like this:
// Warning: pseudo-code // Defining states $stateProvider .state("root", { url: "/", // Any service can be injected into this controller. // You can also define the controller separately and use // "controller: "<NameOfController>" to reference it. controller: function(History){ // History.header factory History.pages.push(History.currentPage); History.currentPage = "/"; } }) .state("search", { url: "/search", controller: function(History, $routeParams) { History.lastSearch = $routeParams } }); app.factory('<FactoryName>',function(){ var serviceObjectSingleton = { pages: [] currentPage: "" lastSearch: {} } return serviceObjectSingleton })
If you're wondering what the difference is between $ routeProvider and $ stateProvider, it's just that $ stateProvider has more features, mostly nested states and views ... I think.