Sorting array of objects by property

前端 未结 4 1740
梦毁少年i
梦毁少年i 2021-02-14 09:48

I have this collection from DataBase:

var items = [{ \'Name\':\'Michael\', \'TypeId\':1 }
        { \'Name\':\'Max\', \'TypeId\':1 }
        { \'Name\':\'Andre\'         


        
4条回答
  •  有刺的猬
    2021-02-14 10:47

    In a template:

  • ...
  • In a controller/service:

    vm.sortedItems = $filter('orderBy')(items, 'TypeId');
    

提交回复
热议问题