Ng-include how to make an orderBy object

I know that Angular filters can only be applied to arrays, not to objects

I am trying to include dynamically added templates using the following code. Everything seems to work fine until you see the order

What I would like to have this order:

Create Book Address

here plunker

0
source share
2 answers

Instead of using an object with a key, why not use an array? ng-repeatSorts the iteration by the index of the iterated object / array.

FORKED DEMO

  $scope.templates = [
    'create.html',
    'book.html',
    'address.html'
  ];
0
source

it looks like angular will get ng-includeby ordering names according to their name,

so when you use

$scope.templates = 
{
  _address : 'address.html',
  _create : 'create.html',
  _book : 'book.html'
};

template , _address comes first _book comes second _create comes third

$scope.templates = 
{
  _a_create : 'create.html',
  _b_address : 'address.html',
  _c_book : 'book.html'
};

Plunker

+1

All Articles