Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can I use fetch() method #33

Open
reza-mazarlou opened this issue Feb 27, 2017 · 1 comment
Open

how can I use fetch() method #33

reza-mazarlou opened this issue Feb 27, 2017 · 1 comment

Comments

@reza-mazarlou
Copy link

reza-mazarlou commented Feb 27, 2017

I use fetch() method like this :

let provinces = new ProvinceRestCollection();

provinces.fetch({
    success: function() {
        //$scope.provinces bind to the selectbox in view
        $scope.provinces = provinces.map(function (person) {
            return person.title;
        })
    }
});

but I want use it like this

let provinces = new ProvinceRestCollection();

provinces .fetch();

add success event listener in rest-collection like this :

let AmpersandRestCollection=require ("ampersand-rest-collection");

module.exports = AmpersandRestCollection.extend({
    url: 'https://jsonplaceholder.typicode.com/posts',
    success: function() {
        //$scope.provinces bind to the selectbox in view
        $scope.provinces = provinces.map(function (person) {
            return person.title;
        })
    }
});
@dhritzkiv
Copy link
Member

@reza-mazarlou try setting the success on the ajaxConfig option. See if that works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants