我無法使用Ember.computed.alias
綁定到對象的屬性。以下是代碼片段。Ember.js屬性綁定不起作用
代碼
(function() {
'use strict';
var book = Em.Object.create({
title: 'Just For Fun',
author: Em.Object.create({
name: 'Linus Torvalds'
}),
authorName: Ember.computed.alias('author.name')
});
// expected "Linus Torvalds", actual: dump of some object (perhaps author)
console.log('Before author name change:', book.get('authorName'));
book.get('author').set('name', 'Linus Torvalds & David Diamond');
// expected "Linus Torvalds & David Diamond", actual: dump of some object (perhaps author)
console.log('After author name change:', book.get('authorName'));
})();
我想自動更新authorName
每當name
內author
變化。
請幫我理解我錯過了什麼。
看起來甚至'Ember.computed.oneWay'不起作用! – codematix 2014-10-27 06:59:08