T
T
Testtest1322014-08-09 11:35:50
JavaScript
Testtest132, 2014-08-09 11:35:50

How to change state in ui-route?

First, I define the states in the main application module:

$urlRouterProvider.otherwise("/fake");

$stateProvider
     .state("loading", {
      views : {
       "" : {
           templateUrl : "partials/loading.html",
           controller  : "AppLoaderController"
        }
      }
   })
     .state("fake", {
        url: "/fake",
        templateUrl :  "partials/fake.html",
        controller  : "AppFakeController" 
     })
...

Then I call the .run method
.run(["$state" , "$urlRouter", function( $state ,  $urlRouter ) {

   if( !Config.loaded ) {
       $state.transitionTo('loading')
     }

}]);

The bottom line is: after initializing the angular application, you need to check if the pictures are loaded, if not, go to the loading state and then redirect to the desired page.
The problem is that $state.transitionTo('loading') does nothing at all. The application simply navigates to /fake

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alternativshik, 2014-08-09
@alternativshik

Perhaps nested states should be used here?

D
DarthJS, 2017-02-23
@DarthJS

as far as I understand the situation, you need to use resolve and turn on the preloader, when the pictures are loaded, the preloader ends and the page opens.
what happens here: Config.loaded ? Where is the image upload function?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question