user2942970
user2942970

Reputation: 57

Ui-router not working on startup

I have set up within angular 1.5 the Ui-router as follows:

app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
  $urlRouterProvider.otherwise('/');
  $stateProvider
  .state('blank', {  url:'/blank', templateUrl: 'home/blank.html' })
 `enter code here` .state('verify', { url:'/verify/:type', templateUrl : 'update/verify.html', controller: function($scope, $stateParams, general) { general.verifyemail($stateParams.type);} })
  .state('home', {  url:'/', templateUrl: 'home/home.html' })
  .state('about', { url:'/about', templateUrl: 'about/about.html' })
  .state('faq', { url:'/faq', templateUrl: 'faq/faq.html' })
  .state('exercise', { url:'/exercise', templateUrl: 'practice/exercise.html' })
  .state('levels', { url:'/levels', templateUrl: 'practice/level.html' })
}]);

the router works when the app is already started but if you extend the url to include the path i.e. myapp/about and paste the url into a new browser window, the browser will open the app but go to the home page. If you paste the same url into the page already loaded, it goes to the right state.

I've obviously set it up wrong but I can't figure out why.

Upvotes: 0

Views: 68

Answers (1)

Abhinav
Abhinav

Reputation: 353

Have you tried to use # before route name?

Like: myapp/#/about

Upvotes: 1

Related Questions