Angular-无法读取属性拆分

时间:2018-08-15 19:46:28

标签: angular promise

然后我使用Promise.all。我的代码:

      getPromiseList(authorList) {

            const list = [];
            const rpps  = JSON.parse(localStorage.getItem('login')).rpps;

            for (let i = 0; i < authorList.length; i++) {
              list.push(new Promise((resolve) => {
                this.dashboardService.getAuthor(authorList[i], rpps).subscribe(informations => {
                  this.authorTab.push(informations);
                  resolve('ok');
                });
              }));
            }
            return (list);
          }

          async getAllAuthor(authorList) {
            this.loadAuthorsTerm = 1;
            this.spinner.hide();
            this.authorList = authorList;
            const list = await this.getPromiseList(authorList);

            Promise.all(list).then(result => {
              console.log(this.authorTab);
              this.current = this.authorTab[0];
              this.initCloudWord();
              this.current.urlGS = 'https://scholar.google.fr/scholar?hl=fr&as_sdt=0,5&q='
                                   + this.current.firstname + '+' + this.current.lastname + '&btnG=';
            });
          }

  initCloudWord() {
    this.clouds = [];
    const keywordsList = this.current.keywords.split('^');

  }

但是,当我执行时,出现此错误:

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'split' of undefined
TypeError: Cannot read property 'split' of undefined

(this.current.keywords是initCloudWord()中的一个字符串

一个主意? 。 谢谢!

0 个答案:

没有答案