UPDATE:
on my html page I'm using as the following:
<section ng-repeat="template in templates">
<ng-include src="template"></ng-include>
</section>
but the problem is that I need specific file in certain order so is there a way I can control the way order is rendering?
I'm trying to orderby an object how do I do that and I have searched online before posting it here.
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>
You can't apply a filter to a plain object, only to arrays.
What you can do is define a method in the controller to convert the object to an array:
and then filter that:
Example
YOU not need to Keep it as Object , include the Key inside data filed , and make it array , after you can Use it as item.key ; and you can remove it with _.omit
filter = function(items){
filtered={};
_.mapObject(items,function(V,K){
if(V.name = 'test'){filtered[K]=V;};
});
return _.sortBy(filtered,'anyFieldSortCoudBeThe KEY it self'); //sortBy will return array sorted };
Credit goes to ryeballar
https://stackoverflow.com/a/27466368/275390
Instead of using a key-value object, why not use an array?
ng-repeat
orders the iteration by the index of the iterated object/array.FORKED DEMO
so i think this would work and it also maintains the same object pointer,