添加输入动态工作不正常 [英] Adding inputs dynamically not working properly

查看:86
本文介绍了添加输入动态工作不正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题想动态添加输入。

I have an issue trying to add inputs dynamically.

我有这样的:

<button ng-click="operations.push({})">Add input</button>

这是增加输入:

<div ng-repeat="operation in operations">
  <input ng-model="operation.detailText">
</div>

我有2列,在那里我有完全一样的,由于一个NG重复,所以,在两列我有添加输入按钮,当我点击按钮添加输入,我加入了输入两列,这是我不想,我需要这些输入只添加到我的工作电流输入。

I have 2 columns, where I have exactly the same due to an ng-repeat, so, in both columns I have the adding inputs button, When I click on the button Add input, I am adding the inputs to both columns, which I don't want, I need to add those inputs only to the current input where I am working on.

我做了一个视频给你看什么,我说什么。
在这里,影片

I made a video for you to see what I am talking about. Here the video

点击此处查看了code: jsbin

Check here for the code: jsbin

推荐答案

我想你使用的是同一阵列同时为 NG-重复

I think you are using the same array for both the ng-repeat that is

operations

所以,当你点击添加按钮它增加了一个空对象,以操作,而且 NG-重复是因为它们都使用相同的阵列的影响。

So when you click on add button it adds an empty object to operations and both the ng-repeat is affected since they both are using the same array.

您需要有不同的阵列,像操作 operations1 ,然后写第二个 NG-重复 operations1

You need to have different arrays, something like operations and operations1 and then write the second ng-repeat with operations1

这篇关于添加输入动态工作不正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆