简体   繁体   English

如何从另一台服务器以角度延迟加载模块?

[英]How to lazy load modules in angular from another server?

How can we lazy load modules of an angular app from another server.我们如何从另一台服务器延迟加载角度应用程序的模块。

{
    path: 'somepath/:id',
    loadChildren: 'js from another server',
}

You can't lazy load modules which is present in another server.您不能延迟加载另一台服务器中存在的模块。 Angular is good for designed Single Page Application (SPA) in which code should be reside inside the URL in which the App Runs. Angular 适用于设计的单页应用程序 (SPA),其中代码应驻留在应用程序运行的 URL 内。

If we need to load the bundles present in another server.如果我们需要加载另一台服务器中存在的包。 First Javascript needs to fetch the js file, related assets and css files.首先 Javascript 需要获取 js 文件、相关资产和 css 文件。 It will parse it and using Angular Interpreter it will update to the DOM.它将解析它并使用 Angular Interpreter 将其更新为 DOM。 It's a time consuming task and it should be avoided by keeping performance and user experience in mind.这是一项耗时的任务,应通过牢记性能和用户体验来避免。

You can push those bundles codes to your server in which app run.您可以将这些捆绑代码推送到运行应用程序的服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM