How can I delay the loading of an Angular 2 application until external data is received?
For instance, if there is an external application on the same HTML page, and I need to pass some data to my app service before initialization. Let's say this data is an API URL, like 'some_host/api/'
, how do I ensure my application doesn't start until this information is retrieved?
Is it feasible to trigger a method in my application from the script of the external app, like so:
application.initApplication('some data string', some_object);
index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>App</title>
<base href="/">
<link>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<script>
application.initApplication('api/url', some_object);
</script>
<app-root
>Loading...</app-root>
</body>
</html>