3

I have a specific logic sequence in my app, and I want a simple way to force my app to start from the welcome page. I am using this:

$urlRouterProvider.otherwise('/pages/welcome');

the problem is that otherwise just play with the unknown URLs and redirect them to the welcome, whereas I want to redirect to the welcome in all cases, even in the registered states.

  • Possible duplicate of [Otherwise on StateProvider](http://stackoverflow.com/questions/16793724/otherwise-on-stateprovider) – notAChance Dec 02 '15 at 10:26

2 Answers2

3

Simply try location.hash = '#/'; like the following:

angular.module('app', []).config(function ($stateProvider, $urlRouterProvider) {

    location.hash = '#/';

    $stateProvider
        .state('welcome', {
            url        : '/pages/welcome',
            templateUrl: 'views/welcome.html',
            controller : 'WelcomeCtrl'
        });

    // if none of the above states are matched, use this as the fallback
    $urlRouterProvider.otherwise('/pages/welcome');        
})
Eymen Elkum
  • 3,013
  • 1
  • 20
  • 34
2

i think you are redirecting to page not any state. You need to mredirect to state.

$urlRouterProvider.otherwise("/state1");
Upalr
  • 2,140
  • 2
  • 23
  • 33
  • thanks @U R, in fact I already using this, but it dosnt work in the case I refresh an internal page –  Dec 02 '15 at 10:17
  • 1
    @MuhammadAmeer Check out this answer - http://stackoverflow.com/questions/16793724/otherwise-on-stateprovider/18761391#18761391 – notAChance Dec 02 '15 at 10:19
  • provide your code on planker .may be the problem is in other part of the code. – Upalr Dec 02 '15 at 10:30