Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ngResource incorrectly parses string arrays into char arrays #2664

@adam-g-pullen

Description

@adam-g-pullen

I have an "activity" resource along with the standard GET/PUT/DELETE operations, the resource has metadata attached to it one example is "dates" (a list unique dates for all activities)

The current implementation of nsResource incorrectly interprets the return as an array of char arrays, when it should be an array of strings

Below is an example of the implementation using typeof.
It is in the then method of the $http({ call

if (data) {
  if (action.isArray) {
    value.length = 0;
    forEach(data, function(item) {
      if (typeof item == 'string') {
        value.push(item);
      } else {
         value.push(new Resource(item));
      }
    });
  } else {
    copy(data, value);
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions