d_z90 d_z90 - 2 years ago 126
AngularJS Question

ng-repeat orderBy issue


I want to plot videos in a defined order according to the
number (from 1 to 5).

<div ng-app="myApp" ng-controller="Ctrl">
<div ng-repeat="vidObj in videoObjects | orderBy: 'id'">

I try to apply the filter
, but apparently is not working properly. Do you have an idea of what I am doing wrong? This is a JSfiddle with the complete code.

Thanks in advance for your replies!

EDIT: Thank you for your replies, but the
file can not change.

Answer Source

The Javascript :

angular.module('myApp', [])
    .controller('Ctrl', function($scope) {
        $scope.videoObjects = {
        "Frank": {
          "id": 1
        "Gerard": {
          "id": 2
        "Rein": {
          "id": 3
        "Ida": {
          "id": 4
        "Ellen": {
          "id": 5

 $scope.arr = Object.keys($scope.videoObjects).map(function(k) { return $scope.videoObjects[k] });


and the HTML

<div ng-app="myApp" ng-controller="Ctrl">
    <div ng-repeat="vidObj in arr | orderBy: 'id'">

I updated your fiddle with this code.. It is working well.

Here is the link http://jsfiddle.net/tirthrajbarot/fc16op6u/39/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download