1
比方說,我有一個像這樣一個觀點:如何使html屬性的值依賴於Ember.js視圖呈現的項目?
App.AnchorView = Ember.View.extend({
tagName: 'a',
attributeBindings: ['href']
});
和一個類定義:
App.Item = Ember.Object.extend({
name: "Unknown Entry",
location: ""
});
和類的一個實例:
App.Item.create({
name: "Google",
location: "http://www.google.com"
});
和我的模板是:
{{#view App.AnchorView}}{{name}}{{/view}}
,我希望它呈現爲:
<a href="http://www.google.com">Google</a>
我該怎麼辦呢?
謝謝,但我特別想知道這是否有可能在改變由視圖本身生成的元素 – Adam