如何仅在获取外部数据后加载 Angular 2 应用程序?
例如,在同一个 html 页面上有外部应用程序,我需要将一些数据传递给我的应用程序服务。想象一下,这是API URL,就像'some_host/api/'
我的应用程序在获取此信息之前不应该被初始化。
是否可以从外部应用程序脚本调用我的应用程序的某些方法,例如:
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>