mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 04:53:58 +08:00
fix(range): set disabled state from FormControl
This commit is contained in:
@ -626,6 +626,13 @@ export class Range extends Ion implements AfterViewInit, ControlValueAccessor, O
|
|||||||
*/
|
*/
|
||||||
onTouched() { }
|
onTouched() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
setDisabledState(isDisabled: boolean) {
|
||||||
|
this.disabled = isDisabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { Component, NgModule } from '@angular/core';
|
import { Component, NgModule } from '@angular/core';
|
||||||
|
import { FormControl, FormGroup } from '@angular/forms';
|
||||||
import { IonicApp, IonicModule, Range } from '../../../..';
|
import { IonicApp, IonicModule, Range } from '../../../..';
|
||||||
|
|
||||||
|
|
||||||
@ -13,6 +14,14 @@ export class Page1 {
|
|||||||
dualValue: any;
|
dualValue: any;
|
||||||
dualValue2 = {lower: 33, upper: 60};
|
dualValue2 = {lower: 33, upper: 60};
|
||||||
|
|
||||||
|
rangeCtrl = new FormControl({value: '66', disabled: true});
|
||||||
|
dualRangeCtrl = new FormControl({value: {lower: 33, upper: 60}, disabled: true});
|
||||||
|
|
||||||
|
rangeForm = new FormGroup({
|
||||||
|
'range': this.rangeCtrl,
|
||||||
|
'dualRange': this.dualRangeCtrl
|
||||||
|
});
|
||||||
|
|
||||||
rangeChange(range: Range) {
|
rangeChange(range: Range) {
|
||||||
console.log(`range, change, ratio: ${range.ratio}, value: ${range.value}`);
|
console.log(`range, change, ratio: ${range.ratio}, value: ${range.value}`);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,20 @@
|
|||||||
<ion-label>dual, step=3, snaps, {{dualValue2 | json}}</ion-label>
|
<ion-label>dual, step=3, snaps, {{dualValue2 | json}}</ion-label>
|
||||||
<ion-range dualKnobs="true" [(ngModel)]="dualValue2" min="21" max="72" step="3" snaps="true"></ion-range>
|
<ion-range dualKnobs="true" [(ngModel)]="dualValue2" min="21" max="72" step="3" snaps="true"></ion-range>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
||||||
</ion-list>
|
</ion-list>
|
||||||
|
|
||||||
|
<form [formGroup]="rangeForm">
|
||||||
|
<ion-list>
|
||||||
|
<ion-item>
|
||||||
|
<ion-label>disabled, range, formControlName</ion-label>
|
||||||
|
<ion-range formControlName="range"></ion-range>
|
||||||
|
</ion-item>
|
||||||
|
|
||||||
|
<ion-item>
|
||||||
|
<ion-label>dual, disabled, formControlName</ion-label>
|
||||||
|
<ion-range dualKnobs="true" formControlName="dualRange"></ion-range>
|
||||||
|
</ion-item>
|
||||||
|
</ion-list>
|
||||||
|
</form>
|
||||||
|
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
Reference in New Issue
Block a user