Unbound properties as arguments for components and views

I am optimizing my Ember app by following some of the tips in this presentation . I am wondering how I can provide unrelated properties as arguments for components and views. For example, in

{{my-component arg=unboundProperty}}

I want it to unboundPropertybe unbound, i.e. it takes as its value its first nonzero value (set after the models were allowed in the route), but does not apply to the component when its value changes. How can i achieve this?

+4
source share
1 answer

, . , , , .

App.FooController = Ember.ObjectController.extend({
  realProperty: 'fooBar',
  unboundProperty: function(){
    return this.get('realProperty');
  }.property()
});



{{my-component arg=unboundProperty}}

App.MyComponentComponent = Ember.Component.extend({
  readOnceArg: function(){
    return this.get('arg');
  }.property()
})
+2

Source: https://habr.com/ru/post/1533621/


All Articles