我有这段代码:
<ul class="unstyled">
<li class="card" ng-repeat="user in users">
<form ng-submit="edit()">
<input type="text" ng-model="editname" size="30"placeholder="add name here">
<input class="btn-primary" type="submit" value="edit">
</form>
</li>
</ul>
哪个card
类将基于users
数组重复。我希望拥有唯一的ng-model
,这样当我编辑其中一个时,它就不会影响其他人。我相信我可以使用$index
。我怎么做
ng-model="editname"
到
ng-model="editname + $index"
或者有更好的方法吗?
答案 0 :(得分:1)
尝试使用ng-repeat实例命名模型
喜欢这个
private static int LINE_LENGTH = 50;
private static int NOT_HAPPY = -1;
public static void main(final String[] args)
{
final int start = Integer.parseInt(args[0]);
final int end = Integer.parseInt(args[1]);
final List<Integer> happy = new ArrayList<Integer>();
for (int i = start; i <= end; i++)
{
if (isHappy(i))
{
happy.add(i);
}
else
{
happy.add(NOT_HAPPY);
}
}
final StringBuilder sb = new StringBuilder(60);
final Iterator<Integer> ii = happy.iterator();
while (ii.hasNext())
{
final int i = ii.next();
if (i == NOT_HAPPY) { sb.append("."); }
else { sb.append(String.format("%d", i)); }
if (sb.length() >= LINE_LENGTH)
{
System.out.println(sb.toString());
sb.setLength(0);
sb.ensureCapacity(60);
}
else if (!ii.hasNext())
{
System.out.println(sb.toString());
}
}
}
您可以通过editname属性
检查1.....7..10..13.....19...23....28..3132...........
44....49..................68.70........79..82...86
....91..94..97..100..103.....109..................
.129130..133.....139...........................167
........176...........188.190.192193.........203..
..208..........219......226...230.....236..239....
..................262263................280.......
...291.293.......301302.......310..313.....319320.
....326..329.331......338.................356.....
362..365.367368.......376..379...383..386....391392
....397......404....409...........................
...440.....446.................464....469........478
........487..490.....496..........................
.............536...................556......563.565
566.........................................608...
.....617....622623........632..635.637638.....644.
...649...653.655656........665.....671.673......680
..683..........694.....700........709......716....
...............736..739........748............761.
763....................784.....790..793........802
...806...........818.820............833..836......
....847............860..863..........874......881.
.....888..........899.901..904..907..910.912913...
....921.923.......931932....937..940.....946......
...........964.....970..973...............989.....
...998.1000
列表中的重复项
答案 1 :(得分:1)
如果您真的关心索引,可以在用户实例上设置索引。然后使用&#39; user.index&#39;作为型号名称。如果没有,您可以使用Anik的答案。