因此,我有一个与企业行模型一起使用的网格设置。列是非常动态的,因此直到对服务器进行第一个行查询时才知道列def。一切正常,但是当请求成功后才设置列def时,如何设置默认的排序状态?
我们已经使用 Angular v6.0.0-beta.3 很长时间了,但最近我们尝试升级到 6.1.3 版本。
我一直无法使用 angular 原理图进行升级,因为它们似乎不支持外部注册表(我们使用 Artifactory),因此我不得不手动升级它,因此很可能我搞砸了一些事情。
目前升级后我得到这个堆栈跟踪:
Uncaught Error: Can't resolve all parameters for LoginComponent: (?).
at syntaxError (compiler.js:1016)
at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getDependenciesMetadata (compiler.js:10917)
at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getTypeMetadata (compiler.js:10810)
at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNonNormalizedDirectiveMetadata (compiler.js:10429)
at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getEntryComponentMetadata (compiler.js:11013)
at compiler.js:11004
at Array.forEach (<anonymous>)
at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver._getEntryComponentsFromProvider (compiler.js:11003)
at compiler.js:10976
at Array.forEach (<anonymous>)
Run Code Online (Sandbox Code Playgroud)
LoginComponent 注入了 AuthService。如果我将 AuthService 放在 LoginComponent 的provide
数组属性中,那么它会停止抱怨该错误,并为另一个组件提供相同的错误。我试过用新providedIn: 'root'
配置替换所有可注射的,但它仍然不起作用。我试过清理 npm 缓存并删除 node_modules ,但仍然是同样的问题。我对我做错的事感到迷失。
在 AOT 中运行实际上正确启动了应用程序,但是在使用某些组件(我认为是材料)时,我得到了这些堆栈跟踪:
ERROR TypeError: a[getSymbolIterator(...)] is not a function
at areIterablesEqual (core.js:5492)
at devModeEqual (core.js:5421) …
Run Code Online (Sandbox Code Playgroud) 仅供参考此问题与Angular Universal有关
我目前正在尝试创建一个缓存GET请求的HttpClient拦截器,并将缓存的响应作为可观察对象返回.
我试着遵循Angular拦截器设置的指南https://github.com/angular/angular/blob/master/aio/content/guide/http.md但我似乎无法让它工作,当我返回时除了next.handle()之外的Observable,订阅不会被触发.
这是一个说明它不起作用的plunker.https://plnkr.co/edit/QzVpuIoj3ZFXgHm7hVW2?p=preview
示例拦截器:
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// if this is cached, return the cached response.
return Observable.of({body: 'Test'});
return next
.handle(customReq)
.do((ev: HttpEvent<any>) => {
if (ev instanceof HttpResponse) {
// Cache this response
}
});
}
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.
我的目标最终是使用NG Universal的传输模块.如果我在拦截器中解决了这个问题,那么我应该让所有工作都准备好了.
编辑:我的假设是错误的.Angular HttpClient Interceptor Caching示例工作得非常好,它必须是Angular Universal,对我来说是失败的.(我使用Angular的工作示例更新了Plunker,以证明它适用于该情况).
这是我用于Angular Universal的拦截器.
constructor(private state: TransferState) {}
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if (request.method !== "GET") {
return next.handle(request);
}
const STATE_KEY = makeStateKey(request.urlWithParams);
const …
Run Code Online (Sandbox Code Playgroud)