Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions app/ui-category/switch/disable-switch/article.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Set `Switch` in `HTML` code
<snippet id='switch-view-html'/>

Disable `Switch` control via setting `isEnable` property to false
<snippet id='disable-switch-code'/>
Set `Switch` in `HTML` code.
Disable `Switch` control via setting `isEnabled` property to false.
<snippet id='disable-switch'/>
22 changes: 12 additions & 10 deletions app/ui-category/switch/disable-switch/disable-switch.component.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<StackLayout sdkExampleTitle sdkToggleNavButton>
<StackLayout class="example-container">
<!-- >> switch-view-html -->
<GridLayout rows="auto auto auto auto" columns="* *" class="m-5">
<Label class="h3 m-15" [text]="sw1.isEnabled ? 'enabled' : 'disabled'" textWrap="true" row="0" col="0"></Label>
<Switch class="m-15" #sw1 checked="true" row="0" col="1"></Switch>
<Label class="h3 m-15" [text]="sw2.isEnabled ? 'enabled' : 'disabled'" textWrap="true" row="1" col="0"></Label>
<Switch class="m-15" #sw2 checked="false" row="1" col="1"></Switch>
<Label class="h3 m-15" [text]="sw3.isEnabled ? 'enabled' : 'disabled'" textWrap="true" row="2" col="0"></Label>
<Switch class="m-15" #sw3 checked="true" row="2" col="1"></Switch>
<Button class="btn btn-primary btn-active" text="Disable switches" (tap)="onTap()" row="3" col="0" colSpan="2" horizontalAlignment="stretch"></Button>
<!-- >> disable-switch -->
<GridLayout rows="auto auto" columns="* *" class="m-5">
<Label class="h3 m-15"
[text]="switch.isEnabled ? 'enabled' : 'disabled'"
textWrap="true" row="0" col="0"></Label>
<Switch #switch class="m-15" row="0" col="1"></Switch>

<Button class="btn btn-primary btn-active"
[text]="switch.isEnabled ? 'Disable switch' : 'Enable switch'"
(tap)="switch.isEnabled = !switch.isEnabled"
row="3" col="0" colSpan="2" horizontalAlignment="stretch"></Button>
</GridLayout>
<!-- << switch-view-html -->
<!-- << disable-switch -->
</StackLayout>
</StackLayout>
17 changes: 0 additions & 17 deletions app/ui-category/switch/disable-switch/disable-switch.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// >> disable-switch-code
import { Component, ViewChild, ElementRef } from "@angular/core";
import { Switch } from "ui/switch";

Expand All @@ -8,20 +7,4 @@ import { Switch } from "ui/switch";
styleUrls: ["./../switch.style.css"],
})
export class DisableSwitchComponent {

@ViewChild("sw1") firstSwitch: ElementRef;
@ViewChild("sw2") secondSwitch: ElementRef;
@ViewChild("sw3") thirdSwitch: ElementRef;

public onTap() {
let firstsw: Switch = <Switch>this.firstSwitch.nativeElement;
let secondsw: Switch = <Switch>this.secondSwitch.nativeElement;
let thirdsw: Switch = <Switch>this.thirdSwitch.nativeElement;

firstsw.isEnabled = false;
secondsw.isEnabled = false;
thirdsw.isEnabled = false;
}

}
// << disable-switch-code