mercredi 18 novembre 2020

How do I update data in the service store in Ember?

I created a service where I declared the store:

store.js:

import Service from '@ember/service';

export default class StoreService extends Service {
  store = {
    lang: 'EN'
  }
}

I also got access to the store from the route:

first.js:

import Route from '@ember/routing/route';
import { inject } from '@ember/service';

export default Route.extend({
  store: inject(),
  model() {
    console.log(this.store);
    return this.store;
  }
});

And the template. first.hbs:

<div class="wrapper">
  <h3>First</h3>
  <hr class="gold">
  <p><button type="button">CN</button></p>
  
</div>


Please tell me how you can change the data in the storage from the route by pressing the "CN" button?

Regards.




Aucun commentaire:

Enregistrer un commentaire