0

I have a complex object that looks like:

   {
      'street35':[
          {'address154': 'name14'},
          {'address244': 'name2'}
      ],
      'street2':[
          {'address15': 'name1'},
          {'address234': 'name2'}
      ]
   }

I'm binding it to the html using the (value, key) in object attribute that angular.js provides. I want to order by the value in this case by the street name. Any suggestions?

0

1 Answer 1

2

You can try this code:

JS:

   $scope.streetsObject = {
      'street35':[
          {'address154': 'name14'},
          {'address244': 'name2'}
      ],
      'street2':[
          {'address15': 'name1'},
          {'address234': 'name2'}
      ]
   }

HTML:

<div ng-repeat="street in streetsObject | orderBy">
    <span ng-repeat"name in street">
    </span>
</div>

The code supposes that you are using angular 1.3.0+.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.