I am working with AngularJS $ stateProvider. To navigate in my application, users switch from state to state using this function:
$rootScope.gotoState = function(stateName) { $state.go(stateName, {}, { location: false } ); };
This allows you to change state and load a new view without changing the URL (location: false) does the trick.
However, when you enter the application (what happens on the page "index.html"), the display URL is "myWebsite / index.html # / tab / index", and the index is the first state of the application. My question is: how can I change it to display only "myWebsite / index.html" ?
NOTE. At the moment, users cannot use the back and forward buttons of their browsers to navigate, because the location is set to false, so if there is a solution that also solves this problem, I'm interested.
Here is the status declaration:
angular.module('ionicApp', ['ionic', 'ngCookies']) .config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) { $ionicConfigProvider.tabs.position('top'); // values: bottom, top $stateProvider .state('tabs', { url: "/tab", abstract: true, templateUrl: "templates/tabs.html" }) .state('tabs.index', { url: "/index", cache:false, views: { 'index-tab': { templateUrl: "home.html" } } }) .state('tabs.profile', { url: "/profile", cache:false, views: { 'profile-tab': { templateUrl: "profile.html" } } }) $urlRouterProvider.otherwise("/tab/index"); }) .run(function($rootScope, $state, $location) { $rootScope.$state = $state; $rootScope.$location = $location; $rootScope.gotoState = function(stateName) { $state.go(stateName, {}, { location: false } ); }; })
I am not very familiar with single-page applications, and I do not know if what I am asking is possible with this structure. If this is not the case, I would be very happy to know what is the best alternative.