I moved state properties from controller to service except queryParams. now I would like to have one of the query param property to service.
Is there any way to achieve this without using observer ?.
controllers/application.js
import Ember from 'ember';
const {computed,observer} = Ember;
export default Ember.Controller.extend({
myService:Ember.inject.service(),
appName: 'Ember Twiddle',
changedAppName:observer('appName',function(){
this.get('myService').changeAppName(this.get('appName'));
}),
actions:{
changeApp(){
this.set('appName','NewEmberApp');
}
}
});
templates/application.hbs
<h1>Welcome to </h1>
<br>
<button >Change</button>
<br>
<br>
<br>
services/my-service.js
import Ember from 'ember';
export default Ember.Service.extend({
appName:'SSS',
changeAppName(param){
this.set('appName',param);
}
});
Aucun commentaire:
Enregistrer un commentaire