user3427612
user3427612

Reputation: 1

Controller binding weirdness

If I have the following controller:

myApp.IndexController = Ember.ObjectController.extend({
  type: 'objectController',
  name: 'my name',
  controller: {name: "my controller name"},
});

you'd expect that {{name}} would yield "my name" and it does.

However {{controller.name}} also yields "my name".

Is there a way to have a property called "controller" (it could be, say, a financial controller), and access through handlebars bindings?

Upvotes: 0

Views: 64

Answers (1)

JJJ
JJJ

Reputation: 2909

controller in the context you mention, refers to indexController. so if you want to access the controller property of indexController, you can do this:

{{controller.controller.name}}

however, I'd advice against the variable name "controller." Ember has several reserved keywords and controller is one of them. Weird things might occur when using reserved keywords, so I'd just stay away from them.

Upvotes: 1

Related Questions