One sided entrances in Ember?
Ember default {{input}}
helper creates a two-way binding. What is the modern way of creating an input element that is only one way?
Google search for "one-way input using ember" gives several add-ons:
- https://github.com/DockYard/ember-one-way-controls
- https://www.npmjs.com/package/ember-one-way-input
but do i need an addition?
source to share
I believe you can achieve this with a helper oneWay()
. Check the following link.
https://www.emberjs.com/api/classes/Ember.Binding.html#toc_one-way-bindings https://guides.emberjs.com/v2.13.0/object-model/bindings/#toc_one-way- bindings
Sample code from the ember guides.
user = Ember.Object.create({
fullName: 'Kara Gates'
});
UserComponent = Ember.Component.extend({
userName: Ember.computed.oneWay('user.fullName')
});
userComponent = UserComponent.create({
user: user
});
// Changing the name of the user object changes
// the value on the view.
user.set('fullName', 'Krang Gatessss');
// userComponent.userName will become "Krang Gatessss"
// ...but changes to the view don't make it back to
// the object.
userComponent.set('userName', 'Truckasaurus Gates');
user.get('fullName'); // "Krang Gatessss"
source to share
You don't need an addon for one way bindings - https://www.emberjs.com/api/classes/Ember.computed.html#method_oneWay
But I would say I found https://github.com/DockYard/ember-one-way-controls quite useful in day to day development.
source to share