| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente |
| richclient:emberjs:td3 [2019/02/24 16:24] – [TD n°3] jcheron | richclient:emberjs:td3 [2019/08/31 14:21] (Version actuelle) – modification externe 127.0.0.1 |
|---|
| <html></div></html> | <html></div></html> |
| |
| | <html><div class="note"></html> |
| | Le plugin **ember-local-storage** remplace le module **ember-localstorage-adapter** auquel la documentation officielle emberJS fait référence. |
| | <html></div></html> |
| |
| Ajouter le plugin **ember-localstorage-adapter** pour stocker des models côté client : | Ajouter le plugin **ember-local-storage** pour stocker des models côté client : |
| |
| <sxh bash;gutter:false> | <sxh bash;gutter:false> |
| ember install ember-localstorage-adapter | ember install ember-local-storage |
| </sxh> | </sxh> |
| |
| Définir le namespace **contact-app**, clé sous laquelle les données seront enregistrées dans le local storage | Définir le namespace **contact-app**, clé sous laquelle les données seront enregistrées dans le local storage |
| <sxh javascript;title:app/adapters/application.js> | <sxh javascript;title:app/adapters/application.js> |
| import LSAdapter from 'ember-localstorage-adapter'; | import Adapter from 'ember-local-storage/adapters/local'; |
| |
| export default LSAdapter.extend({ | export default Adapter.extend({ |
| namespace: 'contact-app' | modelNamespace: 'contact-app' |
| }); | }); |
| </sxh> | </sxh> |
| |
| <sxh javascript;title:app/serializers/application.js> | <sxh javascript;title:app/serializers/application.js> |
| import { LSSerializer } from 'ember-localstorage-adapter'; | export { default } from 'ember-local-storage/serializers/serializer'; |
| | |
| export default LSSerializer.extend(); | |
| </sxh> | </sxh> |
| |