Strange Behavior w/ Retrieving Model from Controller


#1

Very basic question but cannot seem to figure it out since it kind of defies logic. So I am trying to access the controller’s model but using all the available methods seem to output undefined.

All of the following was used:

console.log(this.content);
console.log(this.get('content'));
console.log(this.model);
console.log(this.get('model'));

They all return undefined (well the .get returns empty array). But the strange behavior is that if I do a:

console.log(this);

in the same area, it outputs the correct controller with the correct content, like so:

Class {_subControllers: Array[0], toString: function, __ember1409342467603: "ember628", __ember_meta__: Object, constructor: function…}
__ember1409342467603: "ember628"
__ember_meta__: Object
__nextSuper: undefined
_oldWillDestroy: function superWrapper() {
_subControllers: Array[8]
_super: function superFunction(){
content: Class
    __ember1409342467603: "ember545"
    __ember_meta__: Object
    __nextSuper: undefined
    _oldWillDestroy: function superWrapper() {
    _super: function superFunction(){
    content: Array[8]
    isLoaded: true
    isUpdating: false
    store: Class
    toString: function () { return ret; }
    type: myapp@model:suit:
    willDestroy: function superWrapper() {
    __proto__: Object
toString: function () { return ret; }
willDestroy: function superWrapper() {
__proto__: Object

As you can see, the content is right (array of 8 objects)… so I am really confused why “this.content” is undefined when “this” does have it.


#2

When using

ember generate

you end up with Ember.Controller, not Ember.ObjectController or Ember.ArrayController.

I had the same problem when models were not binding and figured it out after spending many hours. Can you check if this is causing the strange behavior that you are experiencing?


#3

Thanks for the response! But I did end up switching it to an ArrayController from the original Controller it generated.