I'm working with AngularJS $stateProvider. To navigate in my application, users go from state to state, using this function:
$rootScope.gotoState = function(stateName) {
$state.go(stateName, {}, { location: false } );
};
This allows to change state and load the new view without changing the URL (location: false) does the trick.
However, when entering the application (which happens in the page "index.html"), the displayed URL is "myWebsite/index.html#/tab/index", the index being 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 can't use the back and forth buttons of their browsers to navigate since the location is set to false, so if a solution exists that would also solve this problem, I'm interested.
Here is the state 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'm not very familiar with single-page applications, and I don't know if what I ask is even possible with this structure. If it's not, I would be very happy to know what is the best alternative.