GarethFrazer GarethFrazer - 2 years ago 100
Javascript Question

Get all objects from Array in Angular Scope

I am trying to get all objects within an array from a scope in angular. I am using jQuery to get the array but I'm not sure how to get each object from the array without having to define it like [0].


This gives me:


Which I can then select from but I need to get them all in one go.


Answer Source

This will iterate over each item in the array allowing you to do what you want with it. $.each Docs

$.each(angular.element("#scopes").scope().fixtures, function (index, element) {
  // do what you want - as per your comments...
  console.log("Element: " + index);
  console.log("Status: " + element.status);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download