0

I have created two different modules in app.js like:

app.js

angular.module('userModule', []);
angular.module('adminModule', []);  
angular.module('mainApp', ["userModule","adminModule"]);

I want to do like:

if(loggedInUserAdmin)
{
  angular.module('mainApp', ["userModule","adminModule"]);
}
else
{
  angular.module('mainApp', ["userModule"]);
}

And loggedInUserAdmin is a flag that I need to have from server after index.html loads,I would like to know how can I structure my app.js's code so I can wait till a ajax call completed and then I can decide which modules to be injected?

Any help would be appreciated.

Thanks in advance.

3
  • I found this. I think it could be what you are looking for.. stackoverflow.com/questions/12758157/… Jul 15, 2014 at 5:19
  • Hi Ashraf, above link saying about how to inject depedency in a controller,but I want to do it at module level.
    – Gaurav
    Jul 15, 2014 at 5:32
  • 1
    can't you have server write which version to use? Alternatively, can manually bootstrap angular after the ajax call. Give each of your module versions a different name and bootstrap the one that is appropriate
    – charlietfl
    Jul 16, 2014 at 3:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.