Skip to content

Commit 940c0b7

Browse files
authored
fix(ui-category): simplify disable-switch example (#131)
1 parent 6652d1f commit 940c0b7

File tree

3 files changed

+15
-32
lines changed

3 files changed

+15
-32
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Set `Switch` in `HTML` code
2-
<snippet id='switch-view-html'/>
3-
4-
Disable `Switch` control via setting `isEnable` property to false
5-
<snippet id='disable-switch-code'/>
1+
Set `Switch` in `HTML` code.
2+
Disable `Switch` control via setting `isEnabled` property to false.
3+
<snippet id='disable-switch'/>
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<StackLayout sdkExampleTitle sdkToggleNavButton>
22
<StackLayout class="example-container">
3-
<!-- >> switch-view-html -->
4-
<GridLayout rows="auto auto auto auto" columns="* *" class="m-5">
5-
<Label class="h3 m-15" [text]="sw1.isEnabled ? 'enabled' : 'disabled'" textWrap="true" row="0" col="0"></Label>
6-
<Switch class="m-15" #sw1 checked="true" row="0" col="1"></Switch>
7-
<Label class="h3 m-15" [text]="sw2.isEnabled ? 'enabled' : 'disabled'" textWrap="true" row="1" col="0"></Label>
8-
<Switch class="m-15" #sw2 checked="false" row="1" col="1"></Switch>
9-
<Label class="h3 m-15" [text]="sw3.isEnabled ? 'enabled' : 'disabled'" textWrap="true" row="2" col="0"></Label>
10-
<Switch class="m-15" #sw3 checked="true" row="2" col="1"></Switch>
11-
<Button class="btn btn-primary btn-active" text="Disable switches" (tap)="onTap()" row="3" col="0" colSpan="2" horizontalAlignment="stretch"></Button>
3+
<!-- >> disable-switch -->
4+
<GridLayout rows="auto auto" columns="* *" class="m-5">
5+
<Label class="h3 m-15"
6+
[text]="switch.isEnabled ? 'enabled' : 'disabled'"
7+
textWrap="true" row="0" col="0"></Label>
8+
<Switch #switch class="m-15" row="0" col="1"></Switch>
9+
10+
<Button class="btn btn-primary btn-active"
11+
[text]="switch.isEnabled ? 'Disable switch' : 'Enable switch'"
12+
(tap)="switch.isEnabled = !switch.isEnabled"
13+
row="3" col="0" colSpan="2" horizontalAlignment="stretch"></Button>
1214
</GridLayout>
13-
<!-- << switch-view-html -->
15+
<!-- << disable-switch -->
1416
</StackLayout>
1517
</StackLayout>
Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// >> disable-switch-code
21
import { Component, ViewChild, ElementRef } from "@angular/core";
32
import { Switch } from "ui/switch";
43

@@ -8,20 +7,4 @@ import { Switch } from "ui/switch";
87
styleUrls: ["./../switch.style.css"],
98
})
109
export class DisableSwitchComponent {
11-
12-
@ViewChild("sw1") firstSwitch: ElementRef;
13-
@ViewChild("sw2") secondSwitch: ElementRef;
14-
@ViewChild("sw3") thirdSwitch: ElementRef;
15-
16-
public onTap() {
17-
let firstsw: Switch = <Switch>this.firstSwitch.nativeElement;
18-
let secondsw: Switch = <Switch>this.secondSwitch.nativeElement;
19-
let thirdsw: Switch = <Switch>this.thirdSwitch.nativeElement;
20-
21-
firstsw.isEnabled = false;
22-
secondsw.isEnabled = false;
23-
thirdsw.isEnabled = false;
24-
}
25-
2610
}
27-
// << disable-switch-code

0 commit comments

Comments
 (0)