我有以下对象:如何直接在角度4的模板绑定中增加变量?
this.people = [{
name: 'Douglas Pace',
title: 'Parcelivery Nailed The Efficiency',
content: 'Since I installed this app, its always help me book every tickets I need like flight, concert, ' +
'movie or hotel. I don\'t need to install different app for different ticket. The payment is also very easy',
image: '../../assets/img/profile_pics/profile_pic.jpg',
rate: '4.5',
classActive: 'testimonials__selected-visible',
active: true
},
{
name: 'Naseebullah Ahmadi',
title: 'Parcelivery Nailed The Efficiency',
content: 'Since I installed this app, its always help me book every tickets I need like flight, concert, ' +
'movie or hotel. I don\'t need to install different app for different ticket. The payment is also very easy',
image: '../../assets/img/profile_pics/profile_pic.jpg',
rate: '4.5',
classActive: '',
active: false
},
{
name: 'Haseebullah Ahmadi',
title: 'Parcelivery Nailed The Efficiency',
content: 'Since I installed this app, its always help me book every tickets I need like flight, concert, ' +
'movie or hotel. I don\'t need to install different app for different ticket. The payment is also very easy',
image: '../../assets/img/profile_pics/profile_pic.jpg',
rate: '4.5',
classActive: '',
active: false
}
];
,我喜欢这样的循环这样的HTML:
<ng-template ngFor let-person="$implicit" let-variable [ngForOf]="people">
{{variable + 30}}
<ng-template/>
我的问题是,是否有有一个局部变量,并通过30增加它的一种方式对于模板绑定中的ngfor中的每个元素?而不是有方法来增加?
,我有递增从方法变量的问题是,我得到以下错误:
Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked
你需要增加哪个数组的字段 –
目前我只是想创建一个随机变量来增加。我不想在对象中添加一个字段并增加它。这只是为了说明我的问题。但是,我使用一个API,我得到的对象,所以我不能修改。 @sachilaranawaka – James