0

I am working on Angularjs. There are two type of users on my website.

  1. Guest users
  2. Logged in users

Suppose there are 12 views in my Angular app. I want to render only 1 view for Guest user and 12 views for Logged in users.

As far as i read somewhere, Angularjs converts all the files(js,html) in single js then loads it (Correct me if i am wrong) . So, for Guest user it will also render the codes of rest 11 views which i do not want to render which make app little slow. I could use if/else statements to render view according to condition but still it will render rest 11 views for Guest users.

The only workaround i am seeing is to make two apps. Is it possible in Angularjs to define only 1 view for guest and 12 for logged in user in Single App??

NeiL
  • 791
  • 8
  • 35

1 Answers1

0

Things is that, you can't load routes outside of config block or there is not official way to do that.

Though there are some way you can do that. Checkout How to defer routes definition in Angular.js?. Again this is not official, so if angular team changes code for angular, then you need to change your code.

As you have mentioned, one possible solution is create two different angular app. And manage routing between them from server. It is much secure way and simple too.

Community
  • 1
  • 1
dhavalcengg
  • 4,678
  • 1
  • 17
  • 25