大佬教程收集整理的这篇文章主要介绍了angularjs – ng-repeat orderBy对象,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<section ng-repeat="template in templates"> <ng-include src="template"></ng-include> </section>@H_673_1@但问题是我需要特定顺序的特定文件,所以有没有办法控制顺序渲染的方式? @H_673_1@我试图通过一个对象来命令我该如何做到这一点,我在网上搜索后才发布它.
function MyCtrl($scopE) { $scope.templates = { template_address: "../template/address.html",template_book: "../template/book.html",template_create: "../template/create.html" }; <div ng-app ng-controller="MyCtrl"> <ul> <li ng-repeat="(name,path) in templates">{{name}}: {{path}}</li> </ul> </div>@H_673_1@http://jsfiddle.net/abuhamzah/6fbpdm9m/
$scope.templatesAry = function () { var ary = []; angular.forEach($scope.templates,function (val,key) { ary.push({key: key,val: val}); }); return ary; };@H_673_1@然后筛选:
<li ng-repeat="prop in templatesAry() | orderBy:'-key'"> {{prop.key}}: {{prop.val}} </li>@H_673_1@Example
以上是大佬教程为你收集整理的angularjs – ng-repeat orderBy对象全部内容,希望文章能够帮你解决angularjs – ng-repeat orderBy对象所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。