Ионный ввод скрывается сам по себе при вводе адреса электронной почты

Я попытался реализовать страницу, на которой для сброса пароля требуется адрес электронной почты. Но у меня проблема с ионным вводом. Строка ионного ввода автоматически скрывается посередине при вводе адреса электронной почты.

Как я могу это решить? Я не знаю, в чем проблема? Либо с моим HTML, либо CSS, либо TS.

Мой код:

Forgotpwd.html:

<ion-content class="ioncontent" no-bounce padding>
    <div>
        <div text-center fixed-content>
            <div class="login-logo-container">
                <img src="assets/imgs/login_logo.png" />
            </div>
        </div>

        <div class="div-card" fixed-content>
            <label class="labelstyle"> We just need your registered email id to send <br /> your password reset instructions </label>
            <form [formGroup]="forgotpasswordform">
                <ion-row>
                    <ion-item>
                        <ion-icon name="md-mail"></ion-icon>
                        <ion-label color="primary" floating>Email Address</ion-label>
                        <ion-input type="email" [(ngModel)]="vm.emailAddress" formControlName="emailAddress" name="emailAddress"
                                   (keyup)="moveFocus($event,password, true)"></ion-input>
                    </ion-item>
                    <div class="error-message" style="margin-left: 15px" *ngIf="forgotpasswordform.controls.emailAddress.errors && (forgotpasswordform.controls.emailAddress.dirty || forgotpasswordform.controls.emailAddress.touched)">
                        <span *ngIf="forgotpasswordform.controls.emailAddress.errors?.required">Email address is required</span>
                        <span *ngIf="forgotpasswordform.controls.emailAddress.errors?.email">Email address is invalid</span>
                    </div>
                </ion-row>
                <div class="full-width pull-right">
                    <button ion-button icon-end name="submitbutton" type="button" (click)="submitforget()" class="button" color="purple">
                        Submit
                        <ion-icon name="checkmark-circle-outline"></ion-icon>
                    </button>
                    <button ion-button icon-end name="cancelbutton" type="button" (click)="cancel()" class="button" color="purple">
                        Cancel
                        <ion-icon name="close-circle"></ion-icon>
                    </button>
                </div>
            </form>
        </div>
    </div>
</ion-content>

Мой CSS:

page-forgotpassword {

    .full-width {
        width: 100%;
        float: right;
        margin-top: 8%;
    }

    .div-card {
        margin-left: 5%;
        margin-right: 5%;
        margin-bottom: 5%;
        height: 80% !important;
        margin-top: -100% !important;
    }

    .ioncontent {
        background-image: url('../assets/imgs/login_background.jpg');
        // background-image: url('../assets/imgs/login_logo.png');
        background-size: cover;
        overflow: scroll !important;
    }
   .labelstyle{
       color: white;
   }

    .error-message {
        padding-top: 0px !important;
        text-align: left !important;
    }

    .item-inner, ion-item {
        border-bottom-color: transparent !important;
        box-shadow: none !important;
        outline: none !important;
    }

    ion-row {
        background-color: transparent !important;
    }

    ion-item {
        background-color: transparent !important;
    }

    ion-input {
        color: #bdcde7 !important;
    }
}


/*.email {
    border-bottom: 2px solid #00b1ff;
}

.icon-inputs {
    display: flex;
    position: absolute;
    bottom: 0;
    font-size: 18px;
    min-width: 0 !important;
    text-align: left !important;
    color: #00b1ff;
    padding-bottom: 0px;
    margin-left: -9px !important;
    zoom: 0.8;
}


.item-inner, ion-item {
    border-bottom-color: transparent !important;
    box-shadow: none !important;
    outline: none !important;
}

.icon-ends-fget-cancel {
    background-color: #00b1ff;
    border: none;
    color: white;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 30px;
    margin: 4px 2px;
    margin-left: 88%;
    cursor: pointer;
    padding-left: 20px;
    padding-top: 15px;
    padding-bottom: 15px;
    padding-right: 20px;
    border-radius: 50%;
}

.icon-end-check-fgetsubmit {
    background-color: #00b1ff;
    border: none;
    color: white;
    padding-left: 17px;
    padding-top: 15px;
    padding-bottom: 15px;
    padding-right: 17px;
    vertical-align: end;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 30px;
    margin: 4px 2px;
    cursor: pointer;
    margin-left: 65%;
    border-radius: 50%;
}

.submit-button-checkmark-icon-alignment {
    vertical-align: right;
}*/

Мой Forgotpwd.ts:

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, Platform } from 'ionic-angular';
import { ForgotPassword } from '../../models/forgotpassword';
import { FormGroup, FormControl, Validators } from '@angular/forms';
import { AuthenticationService } from "../../services/authentication.service";
import { MessageService } from "../../services/message.service";
import { LoginPage } from '../login/login';

/**
 * Generated class for the ForgotpasswordPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
    selector: 'page-forgotpassword',
    templateUrl: 'forgotpassword.html',
})
export class ForgotpasswordPage {
    vm: ForgotPassword;
    emailpattern: string = "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[a-z]{2,3}$";
    forgotpasswordform: FormGroup;
    forgotpasswordservice: AuthenticationService;
    isPasswordReset: boolean = false;
    statusMessage: string;
    isEmailExist: boolean;
    constructor(public navCtrl: NavController, private platform: Platform, public navParams: NavParams,
        private authenticationService: AuthenticationService,
        private messageService: MessageService
    ) {
        this.vm = new ForgotPassword();
        this.isPasswordReset = false;
        this.statusMessage = '';
        platform.registerBackButtonAction(() => this.myHandlerFunction());
    }

    moveFocus(event, nextElement, isLastControl) {
        if (event.key === 'Enter') {
            if (isLastControl && isLastControl === false)
                nextElement.setFocus();
            else if (isLastControl && isLastControl === true)
                this.submitforget();
        }
    }

    myHandlerFunction() {
        this.navCtrl.push(LoginPage);
    }

    ngOnInit() {
        this.initializeValidators();
    }

    initializeValidators() {
        this.forgotpasswordform = new FormGroup({
            emailAddress: new FormControl('',
                [
                    Validators.required,
                    Validators.email
                ]),
        });
    }

    cancel() {
        this.navCtrl.push(LoginPage);
    }

    submitforget() {
        if (this.forgotpasswordform.valid) {
            this.authenticationService.forgotpassword(this.vm.emailAddress).subscribe((data) => {
                this.isPasswordReset = true;
                this.isEmailExist = data !== 'EmailNotExist';
                if (data === 'EmailNotExist') {
                    this.messageService.alert('This email address does not exist on our system please click here to register');
                } else {
                    this.navCtrl.push(LoginPage);
                    this.messageService.alert('Link to reset the password had been sent to the registered email address');
                }

            });
        } else {
            this.validateAllFormFields(this.forgotpasswordform);
        }
    }
    validateAllFormFields(formGroup: FormGroup) {
        Object.keys(formGroup.controls).forEach(field => {
            const control = formGroup.get(field);
            if (control instanceof FormControl) {
                control.markAsTouched({ onlySelf: true });
            } else if (control instanceof FormGroup) {
                this.validateAllFormFields(control);
            }
        });
    }

}

Вот изображение сценария:

Hidden

Он ведет себя таким образом, что автоматически появляется и исчезает.

0
0
58
1

Ответы 1

попробуйте использовать ионную родную клавиатуру здесь

import { Keyboard } from '@ionic-native/keyboard';

constructor(private keyboard: Keyboard) { }

...

this.keyboard.show();

// this.keyboard.close();

Можете ли вы предоставить мне точное решение? Поскольку я новичок в ionic., У меня нет никаких предварительных знаний об этом.

Thedroider 10.09.2018 12:08

Другие вопросы по теме