angular2仅支持最多9个插值

前端之家收集整理的这篇文章主要介绍了angular2仅支持最多9个插值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我尝试在模板中插入超过9个对象的属性时,我收到以下错误
错误:未捕获(在承诺中):模板解析错误
最多只支持9个插值!

该问题可以转载于:
http://plnkr.co/edit/3M7lw6U4RAuOPacM4rmj?p=preview

<ul>
    <li 
      *ngFor="let lead of leads"
    >
       {{lead.first_name}} {{lead.last_name}} 
        {{lead.primary_email}}  {{lead.primary_phone}}
         {{lead.primary_address_line_1}}  {{lead.primary_address_line_2}}  {{lead.primary_address_city}}  {{lead.primary_address_state}}  {{lead.primary_address_zip}}  {{lead.date_of_birth}}
       <input type="checkBox" [checked]="lead.is_pre_approved" (change)="toggleAttending.emit(lead)" />
       <button (click)="removePerson.emit(lead)">Delete</button>
    </li>
  </ul>

预期/期望的行为
它应该能够打印对象的任意数量属性

解决方法

我认为这不是一个问题,只是一种防止解析器耗尽内存的方法,但重要的是要突出显示每个html元素的这个限制,你可以调整你的模板包装插值表达式在元素中,如下所示:

<ul>
    <li *ngFor="let lead of leads">
        <div>
            {{lead.first_name}} {{lead.last_name}}
        </div>
        <div>
            {{lead.primary_email}} {{lead.primary_phone}}
        </div>
        <div>
            {{lead.primary_address_line_1}} {{lead.primary_address_line_2}} {{lead.primary_address_city}} {{lead.primary_address_state}}
            {{lead.primary_address_zip}} {{lead.date_of_birth}}
        </div>
        <input type="checkBox" [checked]="lead.is_pre_approved" (change)="toggleAttending.emit(lead)" />
        <button (click)="removePerson.emit(lead)">Delete</button>
    </li>
</ul>

猜你在找的Angularjs相关文章