From f9a576ed939969a6a1f88f93b906cbd292db0b45 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Mon, 23 Jan 2017 12:36:46 -0500 Subject: [PATCH] fix(input): pass readonly from ion-input down to native input also adds to placeholder test an input and textarea with readonly that can be toggled fixes #6408 --- src/components/input/input.ts | 20 +++++++++++++++---- .../test/placeholder-labels/app.module.ts | 9 ++++++++- .../input/test/placeholder-labels/main.html | 11 ++++++++++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/components/input/input.ts b/src/components/input/input.ts index bb73636aaf7..dbc0c36c0a7 100644 --- a/src/components/input/input.ts +++ b/src/components/input/input.ts @@ -80,8 +80,8 @@ import { Platform } from '../../platform/platform'; @Component({ selector: 'ion-input,ion-textarea', template: - '' + - '' + + '' + + '' + '' + '' + '
', @@ -96,6 +96,7 @@ export class TextInput extends Ion implements IonicFormInput { _coord: PointerCoordinates; _didBlurAfterEdit: boolean; _disabled: boolean = false; + _readonly: boolean = false; _isTouch: boolean; _keyboardHeight: number; _native: NativeInput; @@ -164,7 +165,7 @@ export class TextInput extends Ion implements IonicFormInput { @Input() placeholder: string = ''; /** - * @input {bool} A clear icon will appear in the input when there is a value. Clicking it clears the input. + * @input {boolean} A clear icon will appear in the input when there is a value. Clicking it clears the input. */ @Input() get clearInput() { @@ -208,7 +209,7 @@ export class TextInput extends Ion implements IonicFormInput { } /** - * @input {bool} If the input should be disabled or not + * @input {boolean} If the input should be disabled or not */ @Input() get disabled() { @@ -226,6 +227,17 @@ export class TextInput extends Ion implements IonicFormInput { this._native && this._native.isDisabled(val); } + /** + * @input {boolean} If the input should be readonly or not + */ + @Input() + get readonly() { + return this._readonly; + } + set readonly(val: boolean) { + this._readonly = isTrueProperty(val); + } + /** * @input {string} The mode to apply to this component. */ diff --git a/src/components/input/test/placeholder-labels/app.module.ts b/src/components/input/test/placeholder-labels/app.module.ts index e04b1caf5aa..d71047c8cef 100644 --- a/src/components/input/test/placeholder-labels/app.module.ts +++ b/src/components/input/test/placeholder-labels/app.module.ts @@ -5,7 +5,14 @@ import { IonicApp, IonicModule } from '../../../../../ionic-angular'; @Component({ templateUrl: 'main.html' }) -export class E2EPage {} +export class E2EPage { + isReadonly: boolean = true; + + toggleReadonly() { + this.isReadonly = !this.isReadonly; + } + +} @Component({ template: '' diff --git a/src/components/input/test/placeholder-labels/main.html b/src/components/input/test/placeholder-labels/main.html index 7b502191b83..6e22d6eeb22 100644 --- a/src/components/input/test/placeholder-labels/main.html +++ b/src/components/input/test/placeholder-labels/main.html @@ -2,6 +2,9 @@ Placeholder Label Text Input + + + @@ -19,6 +22,10 @@ + + + + @@ -37,6 +44,10 @@ + + + +