2015-12-14 37 views
0

鑑於以下元素哪些訪問聚合物鏢1.0.rc靜態屬性

的不同方式.da​​rt

@PolymerRegister('x-custom') 
class XCustom extends PolymerElement { 
    XCustom.created() : super.created(); 

    static const hostAttributes = const { 
    'string-attribute': 'Value', 
    'boolean-attribute': true, 
    'tabindex': 0, 
    }; 
} 

,在

的.html動態 導致
<x-custom string-attribute="Value" boolean-attribute tabindex="0"> 
</x-custom> 

什麼是不同的方式訪問靜態設置hostAttributes在另一個.ht ml和.dart文件,其中x-custom是一個孩子?

+0

能否請您詳細闡述一下你試圖完成的事情? –

回答

0

作爲規定,如果你在What are the different ways to look up elements in Polymer 1.0的方式之一解釋獲得元素的參考,你可以做

var xCustom = ...; 
print(xCustom.attributes['string-attribute']); 
xCustom.attributes['string-attribute'] = 'otherValue'; 

或聲明

<dom-module id="some-element"> 
    <template> 
    <x-custom 
     string-attribute="{{someStringProperty}}"> 
    </x-custom> 
    </template> 
</dom-module> 

(未測試)