2016-09-12 23 views
0

我有一個客戶記錄,並且它有一個地址。在部分內部綁定相關模型並保存它

模板:

{{partial 'address-form' model=model.address}} 

地址形式部分:

{{input value=model.line1}} 

裏面的部分我可以做{{log model.line1}}這工作(它拿起輸入到輸入框中的值)。

但是,回到父模板中,我可以做{{log model.address.line1}},但是這會導致undefined

在路線,地址不填充:

window.console.log(this.currentModel.get('address')); //undefined 

在路由currentModel常規屬性做的工作。

我在做什麼錯?

回答

0

我忘了把實例地址模型在路由的型號掛鉤:

export default Ember.Route.extend(AuthenticatedRouteMixin, { 
    model() { 
    var customer = this.store.createRecord('customer'); 

    customer.set('address', this.store.createRecord('address')); 

    return customer; 
    } 
} 

的部分也應該被直接訪問父範圍的模型。

{{input value=model.address.line1}}