this.allNodesJoin [index] .join不是angular2 +中的函数

时间:2019-04-23 12:58:59

标签: arrays angular function

我想合并所有数组,每个数组的值都像这样- [“ abc”,“ q”]和我想在将每个这样的数组合并到数组池之前使其唯一。因此,我尝试使用.join(“ +”)函数,因为我需要同时使用两个满足特定目的的字符串。

但是我收到此错误-

 this.allNodesJoin[i].join is not a function

如何解决?

app.component.ts

for (var i = 0; i < this.nodesLengthSingular; i++) {


                  this.allNodesJoin.push(this.nodesInfoSingular.records[i]._fields[0], this.nodesInfoSingular.records[i]._fields[1])
                  this.allNodesSingularTotalSelect = this.allNodesJoin[i].join("+");

                }


                // ---------------  remove duplicates  ---------------

                this.uniqNodes = 
      this.allNodesSingularTotalSelect.reduce(function (a, b) {
                  if (a.indexOf(b) < 0) a.push(b);
                  return a;
                }, []);

0 个答案:

没有答案