J
J
JIakki2016-02-17 22:37:59
Angular
JIakki, 2016-02-17 22:37:59

How to make http request in angular 2 before app initialization?

There is such a question: I am making
an application on angular 2 together with google gmail API ( api + authorization)
So the question is, how can I get data (if I have already authorized before) and remove the authorization button during application initialization?
Thanks for the answer

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MNB, 2016-02-18
@MNB

if there is routing:

angular.run(function($rootScope){
  $rootScope.$on('$routeChangeStart', function(e){
    checkAuth().then(function (response) {
      // ... всё ок
    }, function(response){
      // ... всё плохо.
      $location.path('/login');
    });
  });
});

well, or route -> resolve, but the essence is the same.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question