authentication - Ember.js update model after save -
I am currently adding a small amber app to the certification with a simple API in the background:
App. Login = DS.Model.extend ({username: DS.attr (), password: DS.attr (), token: DS.attr ()});
Administrator
App.LoginController = Ember.ObjectController.extend ({// execute your controller verbs here: {submit: function () {var Auto = this; var login = self.get ('model'); login.set ('username', self.get ('username')); login.set ('password', self.get ('password') ); Login.save (). Then (function (result) {// do something here?});}}
});
Any other advice other than 'return an id' which is easy to get the code created before saving, or to return a new code
So I added a custom comfort adapter to finish it:
< Code> App.LoginAdapter = DS.RESTAdapter.extend ({host: 'http://127.0.0.1', createRecord: function (store, type, record) {var p = this._super (store, type, record); Return P.then (function (data) {record.set ('token', data ['token']);});},});
Still wondering if there is an easier or more 'Amber-Way' to do this?
Comments
Post a Comment