title: How to bootstrap an Angular 2 application asynchronously
body: <p>There is an <a href="https://blog.mariusschulz.com/2014/10/22/asynchronously-bootstrapping-angularjs-applications-with-server-side-data" rel="noreferrer">excellent article</a> of how to bootstrap an angular1 application asynchronously. This enables us to fetch a json from the server before bootstrapping.</p>
  
  <p>The main code is here:</p>
  
  <pre><code>(function() {
      var myApplication = angular.module("myApplication", []);
  
      fetchData().then(bootstrapApplication);
  
      function fetchData() {
          var initInjector = angular.injector(["ng"]);
          var $http = initInjector.get("$http");
  
          return $http.get("/path/to/data.json").then(function(response) {
              myApplication.constant("config", response.data);
          }, function(errorResponse) {
              // Handle error case
          });
      }
  
      function bootstrapApplication() {
          angular.element(document).ready(function() {
              angular.bootstrap(document, ["myApplication"]);
          });
      }
  }());
  </code></pre>
  
  <p>How do I achieve the same with Angular 2?</p>