我有以下代码:
import { Injectable } from "@angular/core";
@Injectable()
export abstract class ClientCacheService {
private subscriptionId: string;
protected getId(key :string, prefix:string=""): string {
return `${this.subscriptionId}_${prefix}_${key}`;
}
constructor(subscriptionId: string) {
this.subscriptionId = subscriptionId;
}
abstract setCache(key :string, prefix:string, object: any): void;
abstract getCache(key :string, prefix:string): void;
abstract removeCache(key :string, prefix:string): any;
}
import { ClientCacheService } from "./client-cache.service";
import { Injectable } from "@angular/core";
@Injectable()
export class SessionCacheService extends ClientCacheService {
constructor() {
super("TEST");
}
setCache(key: string, prefix: string, object: any): void {
window.sessionStorage.setItem(this.getId(key, prefix), JSON.stringify(object));
}
getCache(key: string, prefix: string): void | null {
let res = window.sessionStorage.getItem(this.getId(key, prefix));
return res ? JSON.parse(res) : null;
}
removeCache(key: string, prefix: string) {
window.sessionStorage.removeItem(this.getId(key, prefix));
}
}
在生产模式(ng build --prod --output-hashing none --aot false
)中进行编译时出现以下错误:
无法解析e的所有参数
关于此代码,我有两个问题:
SessionCacheService
可以扩展Abstract类吗?@Injectable()
?答案 0 :(得分:1)
df2[] <- lapply(df2, function(x) {
inds <- match(x, df1$id)
ifelse(is.na(inds),x, df1$value[inds])
})
df2
# col1 col2 col3
#0 10 12 54
#1 10 10 54
#2 10 54 21
#3 10 10 5
抽象类关于第2点,只需考虑extend
对Angular意味着什么?这是分层注入器的标志,该类可以通过依赖注入注入到其他类中。注射什么?类实例。可以实例化抽象类吗?不是真的:)
我认为,为@Injectable
进行构建时得到的结果与死代码消除和树抖动有关,我想对所有--prod
实例进行引用跟踪以检查在任何层次调用中是否确实需要它们