【问题标题】:ERROR Error: Error trying to diff 'nombreyo'. Only arrays and iterables are allowedERROR 错误:尝试区分“nombreyo”时出错。只允许使用数组和可迭代对象
【发布时间】:2019-12-05 13:04:24
【问题描述】:

尝试在 html 中绘制类时出现此错误

<li>
    <ul>
      <li *ngFor="let refac of refactormodel" >
        -- word_to_rename: {{refac.word_to_rename}}
        -- renowned_word: {{refac.renowned_word}}
         -- name: {{refac.name}}
      </li>
    </ul>     
  </li>

我希望如果类是空的,我不绘制它,但是是的,并且在绘制时它会给出错误: ERROR 错误:尝试区分“nombreyo”时出错。只允许使用数组和可迭代对象

private refactormodel : getrefactormodel[] = [];

....

this.authService.getrefactor().subscribe((res : getrefactormodel[])=>{
        this.refactormodel = res;
      });

 getrefactor() {
          return this.http.get(apiUrl + 'getRules');
         
      } 

重构模型.ts:

export interface getrefactormodel {
      word_to_rename: String;
      renowned_word: String;
      name: String;

    }

【问题讨论】:

    标签: angular typescript httpclient angular8


    【解决方案1】:

    你有没有这样尝试过?:

      <li *ngFor="let refac of refactormodel" >{{ '-- word_to_rename' + refac.word_to_rename + '...further text fragments...' }}
      </li>
    

    【讨论】:

    • 还是给我,'nombreyo' 是带变量名的文本
    猜你喜欢
    • 1970-01-01
    • 2019-10-26
    • 2021-03-31
    • 1970-01-01
    • 2021-01-09
    • 2018-09-14
    • 1970-01-01
    • 2021-07-23
    • 2020-08-15
    相关资源
    最近更新 更多