EmberJS interaction not working

I just started to study Ember.js and read the eyepiece at http://emberjs.com/ . In the "Binding" section, I simply copied and pasted the following code and executed it in a Chrome browser. Related data (App.husband.get ('homeIncome')) always returned 'undefined'. You know why? I would like to know why my code is not working.

----- HTML Code ------

<html>
<body>
    <script src="js/libs/jquery-1.7.2.js"></script>
    <script src="js/libs/ember-0.9.6.js"></script>
    <script src="js/app.js"></script>
</body>
</html>

----- app.js ------

var App = Ember.Application.create();
App.wife = Ember.Object.create({
  householdIncome: 80000
});

App.husband = Ember.Object.create({
  householdIncomeBinding: 'App.wife.householdIncome'
});

console.log(App.wife.get('householdIncome')); // 80000
console.log(App.husband.get('householdIncome'));// expected 80000

------ Result Result -----------

80000
undefined
+3
source share
1 answer

Em.run.sync(); .get() s. , Ember RunLoop, , . Em.run.sync();, RunLoop . , , , .get() , RunLoop Handlebars, , , , Em.run.sync().

. jsfiddle: http://jsfiddle.net/edwG6/

, http://emberjs.com Bindings. , // Later, after Ember has resolved bindings...

+6

All Articles