2013-05-05 60 views
2

下工作正常,爲什麼我不能使用Dart中的實例化參數選擇內容?

<!DOCTYPE html> 
<html> 
    <body> 
    <element name="x-editable" constructor="EditableComponent" extends="div"> 
     <template> 
     <div style="display: {{editing ? 'block' : 'none'}}"> 
      <content select=".editing"></content> 
     </div> 
     <div style="display: {{editing ? 'none' : 'block'}}"> 
      <content select=".normal"></content> 
     </div> 
     <script type="application/dart" src="xeditable.dart"></script> 
     <script src="packages/browser/dart.js"></script> 
     </template> 
    </element> 
    </body> 
</html> 

它抓住所有的孩子中x-editable.editing.normal,並顯示他們根據布爾editing是否是真還是假。

但是,以下不能正常工作,

<!DOCTYPE html> 
<html> 
    <body> 
    <element name="x-editable" constructor="EditableComponent" extends="div"> 
     <template> 
     <template instantiate="if editing"> 
      <content select=".editing"></content> 
     </template> 
     <template instantiate="if !editing"> 
      <content select=".normal"></content> 
     </template> 
     <script type="application/dart" src="xeditable.dart"></script> 
     <script src="packages/browser/dart.js"></script> 
     </template> 
    </element> 
    </body> 
</html> 

它沒有搶到任何.editing.normal孩子。顯然,我做錯了什麼,但是什麼?

回答

1

不幸的是,<content>在嵌套的模板標籤中不起作用。這很煩人,但有解決方法。你的解決方案設置div的顯示似乎適用於你的情況。在其他情況下,將組件分成多個部分可能更有意義。

+0

你能展示一個將組件分成幾部分的例子嗎? – 2013-05-07 07:10:41

相關問題