简体   繁体   English

AngularJS:ng-repeat指令中的条件

[英]AngularJS: condition in ng-repeat directive

I would like like to know how can i set a condition in a ng-repeat who is in a directive call: 我想知道如何在指令调用的ng-repeat中设置条件:

<map-marker ng-repeat='obj in objects'
  title=      'obj.name'
  latitude=   'obj.last_point().latitude'
  longitude=  'obj.last_point().longitude'
  click=      'state.toggle_selected(obj)'
  icon=       'obj.toggle_icon()'>
</map-marker>

I would like to set a marker for my map only if the obj has last_point(). 我只想在obj具有last_point()的情况下为地图设置标记。 kind of: 的种类:

<map-marker ng-repeat='obj in objects' ng-if='obj.last_point()' ...

My map-marker is a custom directive. 我的地图标记是一个自定义指令。

I can't find a solution. 我找不到解决方案。 Do you know how I can do that please? 你知道我该怎么做吗?

Thanks for help 感谢帮助

What about pre-filter the list in order to it? 怎样对列表进行预过滤呢?

I found this in the forum, it might help you: 我在论坛中找到了它,它可能会对您有所帮助:

https://stackoverflow.com/a/14789258/1683636 https://stackoverflow.com/a/14789258/1683636

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

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