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

How to deserialize #48

@nicooga

Description

@nicooga

I need a way to tell the resource API to deserialize server sent dates as strings ("2016-05-13") into javascript dates so angular-material datepicker doesn't wine about model being an string.

I can't seem to find a way to do this without getting deep into the source of the package. Do you know a simple way to do this?

Currently I'm doing this to override resource's initialize function:

// ....
function factoryConstructor($jsonapi) {
  var resource = $jsonapi.getResource("expenditure");

  resource.initialize = function() {
    var res = this.__proto__.initialize.apply(this);
    res.form.data.attributes["expent-at"] = new Date();
    return res;
  }

  return resource;
}

I would be cool if I could override another function like deserialize(jsonObj) to make this work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions