Skip to content

Parse response with angularjs-rails-resource #95

@duleorlovic

Description

@duleorlovic

It is very easy (<10mins) to start with this nice tool. Thanks. 👍
But I have a problem since I use angular-rails-resource
and I need to parse response, so for example I can call user.save()

Is there any callback that I can use to parse response ?
I see that there is loadPage
so I tried to map response with new User userObject. It works but I have a problem that
it renders previous page (not the current) since in the time when this event callback is called, my vm.usersObject still have old values (from previous page).

// template in jade
bgf-pagination(collection="vm.usersObject" url="'http://localhost:3001/api/v1/users'")

// coffee script
    $scope.$on 'pagination:loadPage', (event, status, config) ->
      console.log config.headers.Range
      return unless vm.usersObject # on first load it is empty
      vm.users = vm.usersObject.map (userObject) -> new User userObject
      console.log vm.usersObject[0].id

I tried with $scope.$apply() but it says $digest already in progress, as expected.

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