Reputation:
So, when I put console.log(Test.globals.user)
I get this:
[id: "1", first_name: "MyFirstName", last_name: "MyLastName"]
How can I get values of first and last name? I've tried this:
Test.globals.user.first_name //undefined
Test.globals.user[first_name] //error - no first_name variable provided
Test.globals.user["first_name"] //undefined
Thank you. :)
Upvotes: 0
Views: 136
Reputation: 30092
The Ext way of doing it would be to have a singleton class to hold global, app wide vars:
Ext.define('Test.globals', {
singleton: true,
user: {
id: 1,
first: 'Foo',
last: 'Bar'
}
});
Ext.onReady(function(){
console.log(Test.globals.user.first);
});
Not Ext example
var Test = {
globals: {
user: {
first: 'Foo'
}
}
};
Upvotes: 1