如别人在做我可以动态加载本地模块plunker这里.但是我如何加载一个外部模块,让我们说另一个服务提供服务的另一个包js.在示例plunker中,src/app.ts具有:
constructor(private viewref: ViewContainerRef,
private resolver: ComponentFactoryResolver,
private loader: SystemJsNgModuleLoader,
private compiler: Compiler){
this.module = new ModuleNode();
//can I make this a non-local script reference somehow?
//like to http://example.net/external.module.bundle.js
this.module.modulePath = "src/dynamic.module#DynamicModule";
this.module.componentName = "TestComponent";
}
Run Code Online (Sandbox Code Playgroud)
有没有办法实现这个目标?
编辑:澄清一下,情景是一组微服务(独立构建,部署等)正在制作spa.所以我的微服务想要从另一个微服务提供的bundle.js动态加载组件/模块.这就是我在编译时没有模块/包的原因.两个微服务之间唯一的合同是bundle文件的url.如果他们更新组件/模块,硬刷新应反映更改,而无需重新部署我的微服务.
ILogger 接口只有一个 Log 方法:
void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter);
Run Code Online (Sandbox Code Playgroud)
应用洞察为我提供了一个丰富的 api,如下所示:
TrackMetric(string name, double value, IDictionary<string, string> properties = null);
TrackException(Exception exception, IDictionary<string, string> properties = null, IDictionary<string, double> metrics = null);
TrackTrace(string message, SeverityLevel severityLevel, IDictionary<string, string> properties);
Run Code Online (Sandbox Code Playgroud)
我应该如何实现自定义 ILogger 并仍然拥有应用程序洞察的所有功能?我能想到的一种方法是定义不同的TState类型,如下所示:
class Trace
{
public string Message {get;set;};
public IDictionary<string, string> Properties;
public Trace(string message, IDictionary<string, string> properties)
{
this.Message = message;
this.Properties = properties;
}
}
Run Code Online (Sandbox Code Playgroud)
然后当我需要跟踪时,我会执行以下操作:
logger.Log<Trace>(LogLevel.Information, …Run Code Online (Sandbox Code Playgroud) 我正在使用带有 aot=true 和 --prod 的 angular cli 构建应用程序,因此应用程序使用 aot 进行编译并且包大小更小,但是我如何以 aot 模式引导应用程序,以便引导程序更快,如本文所述?
当前代码:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/app.module';
if (!environment.local) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
Run Code Online (Sandbox Code Playgroud)
文章提出的代码:
import { platformBrowser } from '@angular/platform-browser';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
//** where is the following file generated by angular-cli? **
import { AppModuleNgFactory } from './app/app.module.ngfactory'; …Run Code Online (Sandbox Code Playgroud) angular ×2
.net-core ×1
angular-cli ×1
angular2-aot ×1
c# ×1
javascript ×1
logging ×1
typescript ×1