2016-08-22 56 views
0

我是Aurelia的新手,在價值綁定中遇到此問題,我不明白爲什麼它不起作用。在Aurelia中綁定2個值

所以我有一個父組件,這是它的HTML使用的子組件的一部分:

<div repeat.for="testWebsite of testWebsites" class="tab-pane ${$index==0? 'active' : ''}" id="${testWebsite.website_id}" role="tabpanel"> 
      <test-website showSummaryBar.bind="testWebsites.length > 1" payload.bind="testWebsite"></test-website> 
     </div> 

測試網站的子組件。在其代碼我聲明爲低於2個綁定變量:

export class TestWebsiteCustomElement { 
@bindable payload; 
@bindable showSummaryBar; 
..... 

有效載荷被成功地結合到testWebsite作爲從父集。但是showSummaryBar始終爲空。我錯過了什麼嗎?提前致謝。

回答

1

可綁定屬性從VM中的camelCase轉換爲視圖中的破折號(也稱爲「kebab case」)。所以showSummaryBar變成show-summary-bar

<test-website show-summary-bar.bind="testWebsites.length > 1" 
       payload.bind="testWebsite"></test-website> 
+0

你說得對。謝謝。 –