我是Angular和JavaScript的新手,无法解码下面的方法。你能帮我理解一下吗?
getSalesgroupunitTx(): string {
if (this . salesgroups !== undefined && this . salesgroupId !== undefined) {
var salesgroup = this.salesgroups.filter((item, index) => {
if (item.salesgroupId == this.salesgroupId) return true;
});、
this.salesgroupunitTx = salesgroup[0].salesgroupunitTx;
}
return this.salesgroupunitTx;
有一些材料......
构造函数中的
this.salesGroupService
.get()
.then(outputJson => {
this.working = false;
console.log(JSON.stringify(outputJson));
this.salesgroups = outputJson.salesgroups;
this.salesgroupId = this.salesgroups[0]['salesgroupId'];
salesGroupService中的。我从API服务器获得输入,如下所示
put(
salesgroupId: number,
salesgroupCd: string,
salesgroupTx: string,
salescategoryId: number,
salesgroupunitTx: string,
updprogramCd: string
): Promise<any> {
const url = `${environment.baseUrl + this.apiUrl}/${salesgroupId}`;
const jsonInput = {
salesgroupCd: salesgroupCd,
salesgroupTx: salesgroupTx,
salescategoryId: salescategoryId,
salesgroupunitTx: salesgroupunitTx,
updprogramCd: updprogramCd
};