Ng-switch在ng-repeat问题中
Ng-switch in ng-repeat issue
我有一个奇怪的问题,让我发疯
我基本上有一个不同类型的文章列表:新闻,推文和视频
我这样渲染它们:
<div ng-repeat="item in items | orderBy:-timestamp track by item.id" ng-switch="item.type">
<?php
include("templates/ang-youtube.html");
include("templates/ang-tweet.html");
include("templates/ang-news.html");
?>
</div>
在每个include中,我做了这样的事情:
<div class="item" masonry-brick ng-switch-when="news">
...content in here
</div>
或
<div class="item" masonry-brick ng-switch-when="tweet">
...content in here
</div>
或
<div class="item" masonry-brick ng-switch-when="youtube">
...content in here
</div>
现在的问题是youtube项目总是首先呈现。条目的顺序(时间戳)被忽略。tweets和news item的渲染是正确的。
如果我删除开关,只是列出项目作为文本,那么一切都在正确的顺序。只要我添加了开关,youtube项目就会再次首先渲染。
你知道我做错了什么吗?
我已经试过像这样移动ng中继器内部的开关:
<div ng-repeat="item in items | orderBy:-timestamp track by item.id">
<div ng-switch="item.type">
<?php
include("templates/ang-youtube.html");
include("templates/ang-tweet.html");
include("templates/ang-news.html");
?>
</div>
</div>
但是没有区别。youtube项目总是先渲染。
如果我检查$作用域。
我也尝试过使用ng-if而不是开关,但得到相同的结果
任何想法?: - (
也试过像这样使用ng-include:
<div ng-include="'templates/ang-{{item.type}}.html'"></div>
但是不行
DOH!需要添加保存顺序属性,如下所示
https://github.com/passy/angular-masonry相关文章:
- 使用ng repeat实现firebaseArray时遇到问题
- 使用ng repeat添加多个视图实例时的范围界定问题
- 在 AngularJS 中使用 ng-repeat 渲染 HTML 值时出现问题
- Angularjs ng-repeat按一个属性过滤,属性重复问题
- orderBy 和 $Index ng-repeat中的问题e
- AngularJS ng-repeat - 空白结果的问题
- AngularJS:使用ng repeat与外部插件集成指令的问题
- Ng-repeat在另一个Ng-repeat中导致分页问题
- Ng-switch在ng-repeat问题中
- 通过ng-repeat将ajax数据填充到表中的问题
- AngularJS ng-repeat数据绑定中的问题
- angular js中的Ng-repeat问题
- ng-repeat声明中的数组问题
- ng-repeat、blurjs、jquery和angular的问题
- AngularJS ng-repeat删除对象中重复键的问题
- 如何使用ng-repeat指令解决性能问题
- 在angular中调用$compile绑定动态HTML后的ng-repeat问题
- 嵌套ng-repeat的问题
- 在角度js中使用ng-repeat,ng-click的问题
- AngularJS的ng-repeat图像加载问题