ianstarz
ianstarz

Reputation: 417

Ember JS preferred way to access ember object properties

What is the preferred way to access properties of ember objects? I often see the the .get() method being used, but wonder why people don't just use dot notation instead. For example in Advice in the Use of Ember Mr. Trek writes the following:

connectOutlets: function(router) {
  router.get('applicationController').connectOutlet('myView');
}

However, the following works just as well in ember-1.0.0-pre.2.min.js (not sure version matters in this case):

connectOutlets: function(router) {
  router.applicationController.connectOutlet('myView');
}

Is there a difference? Or is it a matter of personal taste?

Upvotes: 2

Views: 315

Answers (1)

Trek Glowacki
Trek Glowacki

Reputation: 3621

Bare property access will only work on browsers that support Object.defineProperty https://github.com/emberjs/ember.js/blob/master/packages/ember-metal/lib/accessors.js#L35

Upvotes: 3

Related Questions