No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
親属性による表示ラベル値の設定
親属性による表示ラベル値の設定は、子コンポーネントの表示ラベルを制御する場合に便利です。
コンテナコンポーネントに inner.cmp という別のコンポーネントが含まれているとします。コンテナコンポーネントの属性で inner.cmp の表示ラベル値を設定します。これを行うには、属性型とデフォルト値を指定します。内部コンポーネントの表示ラベルを設定する場合、次の例のように親属性でデフォルト値を設定する必要があります。
次のコンポーネントは、_label 属性のデフォルト値 My Label を含むコンテナコンポーネントです。
1swfobject.registerObject("clippy.codeblock-0", "9");<aura:component>
2 <aura:attribute name="_label"
3 type="String"
4 default="My Label"/>
5 <ui:button label="Set Label" aura:id="button1" press="{!c.setLabel}"/>
6 <auradocs:inner aura:id="inner" label="{!v._label}"/>
7</aura:component>次の inner コンポーネントには、テキストエリアコンポーネントおよびコンテナコンポーネントで設定された label 属性が含まれます。
1swfobject.registerObject("clippy.codeblock-1", "9");<aura:component>
2 <aura:attribute name="label" type="String"/>
3 <ui:inputTextarea aura:id="textarea"
4 label="{!v.label}"/>
5</aura:component>次のクライアント側のコントローラアクションで表示ラベル値を更新します。
1swfobject.registerObject("clippy.codeblock-2", "9");({
2 setLabel:function(cmp) {
3 cmp.set("v._label", 'new label');
4 }
5})コンポーネントが初期化されると、My Label という表示ラベルのボタンおよびテキストエリアが表示されます。コンテナコンポーネントのボタンがクリックされると、setLabel アクションによって、inner コンポーネントの表示ラベル値が更新されます。このアクションによって label 属性が検索され、その値が new label に設定されます。