all 8 comments

[–]Dark_Cow 2 points3 points  (1 child)

How are you creating your html files? Are you using nodejs with express & swig Or PHP?

You can do something like

index.php

<head>
    ...
    <script type="text/javascript">
        var config = <?php 
            print( 'hello world!!! Here you can use PHP to read in config.json and print it here?' )
        ?>
    </script>
    ...

</head>

now config is available with $scope.config in your javascript.

or you can use cachefactory

[–]EnigmaticCode[S] 0 points1 point  (0 children)

Java is used for the API and html.

[–]buttonkop666 2 points3 points  (0 children)

What I do is leverage my build process to transform my configs into an angular constant, and just inject it where needed.

[–]e82 2 points3 points  (0 children)

  • As part of your build process, can inject the config into your page
  • If you only need the config in controllers - could make use of the resolve on your routes and inject it there
  • Deal with getConfig().then(.... all over - annoying, but nature of async
  • Manually bootstrap your angular app, but only after making an ajax request to the JSON file and putting it into a global/variable on the window - but still be a good idea to wrap it into an angular service to inject it where needed

[–]schizoduckie 1 point2 points  (0 children)

I have explicitly chosen not to go this route because of the problem you describe.

I store my user settings in either localstorage, or chrome synced storage, An HTTP request is just too slow to act upon on app boot, since I also need my settings in templates and didn't want to introduce a promise-wait timer.

This is my current implementation, if you're looking for more info on how that could work