<ons-switch>要素のAngularディレクティブです。
スイッチを表示するコンポーネントです。
ons-switch要素はswitch UIを作ることができます。ons-switchに値を指定する場合には、[value]バインディングを使って値を指定します。
@Component({
selector: 'app',
template: `
<ons-switch [value]="target"></ons-switch>
`
})
export class AppComponent {
target: boolean = true;
}
ons-switchの値を補足するには、(change)イベントバインディングを次のように記述します。
@Component({
selector: 'app',
template: `
<div>
<div><ons-switch [value]="target" (change)="target = $event.target.checked"></ons-switch></div>
<div>{{target ? 'on' : 'off'}}</div>
</div>
`
})
export class AppComponent {
target: boolean = true;
}
| 名前 | 型 / デフォルト値 | 概要 |
|---|---|---|
| modifier | String | スイッチの表現を指定します。 Optional. |
| disabled | スイッチを無効の状態にする場合に指定します。 Optional. | |
| checked | スイッチがONの状態にするときに指定します。 Optional. | |
| input-id | String |
Specify the id attribute of the inner <input> element. This is useful when using <label for="..."> elements.
(翻訳中)
Optional.
|
| 名前 | 概要 |
|---|---|
| checked |
スイッチがONの場合にtrue。
|
| value | The current value of the input. (翻訳中) |
| disabled |
無効化されている場合にtrue。
|
| checkbox | コンポーネント内部のcheckbox要素になります。 |
| Name | 概要 |
|---|---|
| material | Material Design switch (翻訳中) |
| シグネチャ | 概要 |
|---|---|
| focus() | Focuses the switch. (翻訳中) |
| blur() | Removes focus from the switch. (翻訳中) |
Focuses the switch. (翻訳中)
Removes focus from the switch. (翻訳中)
| 名前 | 型 | 概要 |
|---|---|---|
| value |
ons-switchコンポーネントに設定する値を指定します。
|
| 名前 | 型 | 概要 |
|---|---|---|
| valueChange | 値が変更された時に発火します。 |
Onsen UIに関する質問は、Stack Overflowにてonsen-uiタグを付与してください。Onsen UIチームはあなたの問題解決をお手伝いします。
バグ報告や機能要望については、GitHub Issuesに記載をお願いいたします。
あわせて、下記の情報も参考にしてください。