EmberRESTless是Ember.js的轻量级数据持久层库。用来跟远程的持久层进行通信(诸如JSONAPI),并映射数据到你客户端的JavaScriptEmber应用。
一些示例代码:
App.Person=RL.Model.extend({firstName:RL.attr('string'),lastName:RL.attr('string'),birthday:RL.attr('date'),createdAt:RL.attr('date',{readOnly:true});//read-onlyattributeswon'tgetsentbackuptotheAPI.});定制转换器:App.RESTAdapter.registerTransform('formattedDate',{deserialize:function(serialized){//returncustomdatestring},serialize:function(deserialized){//returncustomdatejsonformat}});
评论