简体   繁体   English

ng-repeat中未触发AngularJS ng-click事件

[英]AngularJS ng-click event not firing within ng-repeat

I have a list of tags built from a JSON object... 我有一个从JSON对象构建的标签列表...

<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. 但是click事件不会触发以过滤图像。 If I manually build the list of tags like below the click event works... 如果我手动构建标签列表,例如click事件,则可以使用...

<span ng-click="search = { tag: 'Character'}">Character</span>
<span ng-click="search = { tag: 'Sitcom'}">Sitcom</span>

But inside the ng-repeat they do not. 但是在ng-repeat内部却没有。 Let me know if you need any other details! 让我知道您是否需要其他详细信息! Thanks 谢谢

Like @Cherniv suggested in the first comment: use $parent.search so assing to the parent scope. 就像在第一条评论中建议的@Cherniv一样:使用$parent.search来赋值给父作用域。

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. 我主要是将其添加为答案,以便可以接受,因为虽然实际上已解决了该问题,但乍一看它似乎还没有答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM