AngularJS NG-click事件不NG重复内发射 [英] AngularJS ng-click event not firing within ng-repeat
问题描述
我已经从一个JSON对象内置的标签列表...
I have a list of tags built from a JSON object...
<div ng-repeat="comedian in comedians.details | orderBy: 'tag' | unique: 'tag'">
<span ng-click="search = { tag: comedian.tag }">{{ comedian.tag }}</span>
</div>
和来自同一个对象建立图像列表...
And a list of images built from the same object...
<div ng-repeat="comedian in comedians.details | orderBy: 'name' | filter:search:strict">
<img width="50" src="{{ comedian.image }}" alt="{{ comedian.name }}">
</div>
这两个列表建立符合市场预期。但是,单击事件不触发过滤图像。如果我手动生成的标记列表如下图所示单击事件的作品...
Both lists build as expected. But the click event is not firing to filter the images. If I manually build the list of tags like below the click event works...
<span ng-click="search = { tag: 'Character'}">Character</span>
<span ng-click="search = { tag: 'Sitcom'}">Sitcom</span>
但里面NG-重复他们不这样做。让我知道如果你需要任何其他细节!谢谢
But inside the ng-repeat they do not. Let me know if you need any other details! Thanks
推荐答案
像@Cherniv在第一个评论所说:使用 $ parent.search
所以assing父范围
Like @Cherniv suggested in the first comment: use $parent.search
so assing to the parent scope.
我主要将它作为一个答案,因此它可以被接受的,因为这个问题看起来pretty悬而未决一见倾心,而它实际上解决了。
I'm mostly adding this as an answer so it can be accepted, since this question looks pretty unanswered at first sight, while it's actually solved.
这篇关于AngularJS NG-click事件不NG重复内发射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!