angular.js - How to create a new variable in repeat item in angular?
PHP中文网
PHP中文网 2017-05-15 17:09:44
0
3
721

1. There are only x and y in the data. I want to create a new variable item.x_y

<p ng-repeat="item in items">
  <span> {{item.x}} </span>
  <span> {{item.y}} </span>
  <span> {{item.x_y}} </span>
</p>

2. I am still in repeat, is it possible to customize a function? item.function only operates on the data of this item

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
phpcn_u1582

I usually traverse the items,给每一项加x_yattributes.
The performance is so poor, others must have a better way.

我想大声告诉你

Why not add attributes on the server side? Don’t put too much pressure on the front end. If this attribute is only for front-end display, it can be operated without adding the attribute. {{You can write your operation logic for xy here, try not to add attributes here}}. For example, if you want to add a new value of x-y, you can write it like this:
{{item.x - item.y}}

仅有的幸福

Add attributes to controller

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template