mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 21:15:24 +08:00
feat(Input): added functionality for clear input option on ion-input
Implemented function to handle when the clearInput button is pressed on an ion-input element
This commit is contained in:
@ -105,6 +105,13 @@ export class TextInput extends InputBase {
|
||||
inputFocused(event) {
|
||||
this.focus.emit(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
clearTextInput() {
|
||||
this._value = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
5
ionic/components/input/test/clear-input/e2e.ts
Normal file
5
ionic/components/input/test/clear-input/e2e.ts
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
it('should clear input', function() {
|
||||
element(by.css('.e2eClearInput')).click();
|
||||
expect(by.css('.e2eClearInput').getText()).toEqual('');
|
||||
});
|
11
ionic/components/input/test/clear-input/index.ts
Normal file
11
ionic/components/input/test/clear-input/index.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import {App} from 'ionic-angular';
|
||||
|
||||
|
||||
@App({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class E2EApp {
|
||||
constructor() {
|
||||
this.myValue = 'value';
|
||||
}
|
||||
}
|
20
ionic/components/input/test/clear-input/main.html
Normal file
20
ionic/components/input/test/clear-input/main.html
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
<ion-toolbar>
|
||||
<ion-title>Clear Input</ion-title>
|
||||
</ion-toolbar>
|
||||
|
||||
|
||||
<ion-content>
|
||||
|
||||
|
||||
<ion-list>
|
||||
|
||||
<ion-item>
|
||||
<ion-label>Text 1:</ion-label>
|
||||
<ion-input class="e2eClearInput" [(ngModel)]="myParam" clearInput></ion-input>
|
||||
</ion-item>
|
||||
|
||||
|
||||
</ion-list>
|
||||
|
||||
</ion-content>
|
Reference in New Issue
Block a user