为每个元素提供唯一标识符 `ng-repeat` 为了 DOM 操纵

.div/ng-repeat='item in items'/ 
button/id='ID{{$index}}'/ No Hi

button/id='anotherID1'/ Hi


在相关指令内 Angular


$/'#ID1'/.on/'click', function// {alert/'hi'/;}/; // does not work 

$/'#anotherID1'/.on/'click', function// {alert/'hi'/;}/; // works


我在做 DOM 我需要独特的操纵 ID 对于元素 ng-repeat. 另请提供是否执行操纵 DOM 在某种方之上。

编辑: @tymeJV:-


style.
.ques {
height: 50px;
overflow:hidden;
}



<div ng-repeat="item in items">
<div class="ques"> {{item.ques}}
</div>
<button id="ID{{$index}}"> No Hi </button>
</div>


// 指令代码: - 放大身高
<div class="ques">


</div>
<div class="answer_text">
首先,如果你使用 Angular, 建议遵守标准指令。 Angular 对于听众,而不是返回 jQuery. 因此,而不是 jQuery
on

使用属性
ng-click

对于事件 HTML, 你想绑一个听众 Angular.

例如:

HTML

:


<button ng-click="doStuff//">
</button>


控制器

:


$scope.doStuff = function // {
//perform action
};


存储独特 ID 使用每个元素创建
ng-repeat

, 添加呼叫参数如何
doStuff

通过 ID:
ng-click="doStuff/item.ID/"

并在方法中访问它
$scope.doStuff

?
</div>
<div class="answer_text">
id={{'flowchartWindow'+$index}} 这个对我有用
</div>
<div class="answer_text">
尝试
纽扣/标识符= {{index 'ID'+$}}/
</div>
<div class="answer_text">
适用于我。

http://plnkr.co/edit/llSc8o?p=preview
因此,我怀疑了 sushain97 对,问题不是你的使用方式 angular /绑定事件到侧面/.
</div>
<div class="answer_text">
对于动态分配的标识符。 句法
$/'#ID1'/.on/'click', function// {alert/'hi'/;}/;

略微改变


$/'#YourWrapperID'/.on/'click','#id1' , function//{
alert/'hi'/;
}/;


伟大的工作!
</div>
已邀请:

石油百科

赞同来自:

首先,如果你使用 Angular, 建议遵守标准指令。 Angular 对于听众,而不是返回 jQuery. 因此,而不是 jQuery
on

使用属性
ng-click

对于事件 HTML, 你想绑一个听众 Angular.

例如:

HTML

:


<button ng-click="doStuff//">
</button>


控制器

:


$scope.doStuff = function // {
//perform action
};


存储独特 ID 使用每个元素创建
ng-repeat

, 添加呼叫参数如何
doStuff

通过 ID:
ng-click="doStuff/item.ID/"

并在方法中访问它
$scope.doStuff

?

喜特乐

赞同来自:

id={{'flowchartWindow'+$index}} 这个对我有用

卫东

赞同来自:

尝试
纽扣/标识符= {{index 'ID'+$}}/

小姐请别说爱

赞同来自:

适用于我。

http://plnkr.co/edit/llSc8o?p=preview
因此,我怀疑了 sushain97 对,问题不是你的使用方式 angular /绑定事件到侧面/.

喜特乐

赞同来自:

对于动态分配的标识符。 句法
$/'#ID1'/.on/'click', function// {alert/'hi'/;}/;

略微改变


$/'#YourWrapperID'/.on/'click','#id1' , function//{
alert/'hi'/;
}/;


伟大的工作!

要回复问题请先登录注册