Reputation: 6108
I have an AngularJS 1.0.7 web application. When I load my site in a browser I type www.domainname.com. The browser loads the page and immediately my browser url changes to www.domainname/home.
How can avoid this? I would like the browser shows www.domainname.com when I´m in index.html
UPDATE:
Please see my app.js:
'use strict';
// Declare app level module which depends on filters, and services
angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives', 'myApp.controllers'])
.config(['$routeProvider', '$httpProvider', '$locationProvider',function($routeProvider, $httpProvider, $locationProvider) {
// use the HTML5 History API
$locationProvider.html5Mode(true);
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common["X-Requested-With"];
$routeProvider.when('/about', {templateUrl: 'partials/about.html', controller: 'AboutCtrl'});
$routeProvider.when('/contact', {templateUrl: 'partials/contact.html', controller: 'HomeCtrl'});
// More routing
$routeProvider.when('/home', {templateUrl: 'partials/home.html', controller: 'HomeCtrl'});
// More routing
$routeProvider.otherwise({redirectTo: '/home'});
}])
.config(function(AngularyticsProvider) {
AngularyticsProvider.setEventHandlers(['Console', 'GoogleUniversal']);
}).run(function(Angularytics) {
Angularytics.init();
});
Upvotes: 0
Views: 203
Reputation: 5242
It should work if you replaced:
$routeProvider.otherwise({redirectTo: '/home'});
by
$routeProvider.otherwise({redirectTo: '/'});
and added:
$routeProvider.when('/', {templateUrl: 'partials/home.html', controller: 'HomeCtrl'});
NOTE: and as @isherwood rightly commented below:
$routeProvider.when('/home', {templateUrl: 'partials/home.html', controller: 'HomeCtrl'});
can be removed altogether, to avoid having both '/' and '/home' pointing to the same route.
Upvotes: 2