Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember App Kit Binding name resolution

What is the correct string representation of a resource to pass for property bindings in Ember app kit?

I have tried both of the following:

import Dependency from 'app/utils/utility';
export default Em.ObjectController.extend({
  sampleBinding: 'Dependency.value'
});

export default Em.ObjectController.extend({
  sampleBinding: 'utils:utility.value'
});

But the binding is not working in either case.

Any help is appreciated.

Thanks!

like image 960
dvingo Avatar asked Feb 20 '26 12:02

dvingo


1 Answers

I've been researching this myself and came across a few things.

It seems that binding in that way is somewhat deprecated in favor of using computed properties or aliases. Check out the comments on the answer for this SO question: What's the difference between Ember.computed.alias and an Ember.binding?

Or more specifically the comments on this github issue: https://github.com/emberjs/ember.js/issues/1164#issuecomment-23200023).

Part of the reasoning seems to be an aversion to using global/absolute paths. Also you probably don't want to bind to the class definition, but an actual instance of the class. I'm not quite sure what your utility class is, but if it were a controller the idea would be something like this:

export default Em.ObjectController.extend({
  needs: ['utility'],
  aliasedVariable: Ember.computed.alias('controllers.utility.variableOnUtility')
});

Check out the answer for this SO question: Ember.js: data-binding between controllers

Also this section of the ember guide: http://emberjs.com/guides/controllers/dependencies-between-controllers/

like image 115
Aaron Storck Avatar answered Feb 22 '26 02:02

Aaron Storck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!