我正在尝试创建一个处理程序,该处理程序将根据此“资源”是否有“类别”来创建类别数组。最后一个方法引发错误。 错误TypeError:“ this.allProjectResources未定义”
value_type == int
答案 0 :(得分:0)
将类变量初始化为空数组
public allProjectResources: Resource[] = [];
public allResourceCategories: ResourceCategory[] = [];
此外,您应该在getAllResourcesByProjId()
方法中分配空数组,而不要更改length属性
getAllResourcesByProjId(projid: number) {
if (!(isNullOrUndefined(this.allProjectResources))) {
// this.allProjectResources.length = 0;
this.allProjectResources = [];
}
...
}