JavaScript AngularJS: do not load view until first query return success (not 401 response) angularjs load view dynamically,angularjs load view,angularjs load view

In my app (generated with yeoman) i have such structure:

view:

index.html with ng-view for rendering controller view

controller:

every controller try to get some data with api urlm like:

$scope.getArticles = function() {
  $http.get(settings.apiBaseUri + '/app/articles/', {
      headers: {
        'Content-Type': 'application/json',
        'Pragma': 'no-cache',
        'Cache-Control': 'no-cache',
        'If-Modified-Since': ''
      }
    })
    .success(function(response) {
      /* do some magic here :) */
    });
};

$scope.getArticles();

and so in every controller (+ many other queries)

and now i'm a little bit confused: how to do not render anything, until my first request get 200 but not 401?

here is my interceptor:

var deleteAuth = function(){
  $location.path('/signin');
  delete $localStorage.authStatus;
};

var responseError = function(rejection) {
  ...
  if (rejection.status === 401 || rejection.status === 403) {
    authStatus = $localStorage.authStatus;
    if (authStatus && authStatus.isAuth && authStatus.authToken && !ipCookie('authToken') && !renewTokenAttempt) {
      deleteAuth();
    }
  }
  ...
  return $q.reject(rejection);
};

and all works almost 'as must be', but...

every time, i get my index.html loaded (with sidebar, logo etc) and only then i try to get (for example) my articles, and then, if i get 401 i'm redirected to auth-page and this is not so good: becouse i see small blink with all styles, and only then login page.

Is it real, to check first, if i get 200, and only then render page with sidebar etc, and if not: then auth-page.

How to do that?

i saw some solutions in web, but all they are huge, i need something really fast and simple)

Answer:1

Is it possible to have multiple clients to the same UDP server ? I'd like to broadcast the same data to all connected clients. Here would be a starting sample, if it helps somehow ... // Server var ...

Is it possible to have multiple clients to the same UDP server ? I'd like to broadcast the same data to all connected clients. Here would be a starting sample, if it helps somehow ... // Server var ...

My Node script has this in it: var connection = mysql.createConnection(...); connection.connect(); connection.query(/*sql query*/, function(err, rows, fields){ app.get('/', function(req, res){ ...

My Node script has this in it: var connection = mysql.createConnection(...); connection.connect(); connection.query(/*sql query*/, function(err, rows, fields){ app.get('/', function(req, res){ ...

  1. node js jade
  2. node js jade tutorial
  3. node js jade example
  4. node js jade template
  5. node.js jade vs ejs
  6. node js jade table example
  7. node.js jade template tutorial
  8. node js jade vs pug
  9. node js jade bootstrap
  10. node.js jade alternatives
  11. node js jade table
  12. node js jade button onclick
  13. node js jade vs handlebars
  14. node js jade form
  15. node js jade template engine
  16. node js jade to html
  17. node js jade mysql
  18. node js jade css
  19. node.js jade template variables
  20. node js jade tutorial pdf

I'm trying to dynamically add new key/value pairs to an existing json map using jquery/javascript. An example of my structure is as follows: var widgetTypes = { "CLASS_A": { "A1": "A1 ...

I'm trying to dynamically add new key/value pairs to an existing json map using jquery/javascript. An example of my structure is as follows: var widgetTypes = { "CLASS_A": { "A1": "A1 ...

  1. adding key values to dictionary python
  2. adding key values to dictionary c#
  3. adding key values in web.config

I've a written a JavaScript that opens a specific page in the "content" div when I click on a link. HTML: <li><a href='#' onclick="load_shift_test()">Soft Drinks</a></li> JS:...

I've a written a JavaScript that opens a specific page in the "content" div when I click on a link. HTML: <li><a href='#' onclick="load_shift_test()">Soft Drinks</a></li> JS:...