mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +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() { }
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
setDisabledState(isDisabled: boolean) {
|
||||
this.disabled = isDisabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { FormControl, FormGroup } from '@angular/forms';
|
||||
import { IonicApp, IonicModule, Range } from '../../../..';
|
||||
|
||||
|
||||
@ -13,6 +14,14 @@ export class Page1 {
|
||||
dualValue: any;
|
||||
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) {
|
||||
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-range dualKnobs="true" [(ngModel)]="dualValue2" min="21" max="72" step="3" snaps="true"></ion-range>
|
||||
</ion-item>
|
||||
|
||||
</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>
|
||||
|
Reference in New Issue
Block a user