I would like to know what is the correct way to make an ajax call from an ember component. for example
I want to create a reusable component that makes an employee search by employee's Id, then when the response comes back from the server I want to update the model with the data from the ajax response.
I don´t know if this is the correct way to do it, I'm really new on emberjs.
export default Ember.Controller.extend({
ajax: Ember.inject.service(),
actions: {
doSearch() {
showLoadingData();
var self = this;
this.get('ajax').post('http://ift.tt/2iRlU5P', { "id": this }).then(function(data) {
self.set('model.name', data.name);
self.set('model.position', data.position);
hideLoadingData();
});
}
}});
Aucun commentaire:
Enregistrer un commentaire