मेरे मामले में, मुझे अगले बटन एंड्रॉइड और आईओएस दोनों के लिए एक फॉर्म के भीतर नहीं मिल रहा है। मैं केवल कर रहा हूँ। इसलिए मैंने निम्नलिखित निर्देशों का उपयोग करके अगले के रूप में संभाला।
import { Directive, HostListener, Output, EventEmitter, ElementRef, Input } from '@angular/core';
import { Keyboard } from '@ionic-native/keyboard';
@Directive({
selector: '[br-data-dependency]' // Attribute selector
})
export class BrDataDependency {
@Output() input: EventEmitter<string> = new EventEmitter<string>();
@Input('br-data-dependency') nextIonInputId: any = null;
constructor(public Keyboard: Keyboard,
public elementRef: ElementRef) {
}
@HostListener('keydown', ['$event'])
keyEvent(event) {
if (event.srcElement.tagName !== "INPUT") {
return;
}
var code = event.keyCode || event.which;
if (code === TAB_KEY_CODE) {
event.preventDefault();
this.onNext();
let previousIonElementValue = this.elementRef.nativeElement.children[0].value;
this.input.emit(previousIonElementValue)
} else if (code === ENTER_KEY_CODE) {
event.preventDefault();
this.onEnter();
let previousIonElementValue = this.elementRef.nativeElement.children[0].value;
this.input.emit(previousIonElementValue)
}
}
onEnter() {
console.log("onEnter()");
if (!this.nextIonInputId) {
return;
}
let nextInputElement = document.getElementById(this.nextIonInputId);
// On enter, go to next input field
if (nextInputElement && nextInputElement.children[0]) {
let element: any = nextInputElement.children[0];
if (element.tagName === "INPUT") {
element.focus();
}
}
}
onNext() {
console.log("onNext()");
if (!this.nextIonInputId) {
return;
}
let nextInputElement = document.getElementById(this.nextIonInputId);
// On enter, go to next input field
if (nextInputElement && nextInputElement.children[0]) {
let element: any = nextInputElement.children[0];
if (element.tagName === "INPUT") {
element.focus();
}
}
}
}
const TAB_KEY_CODE = 9;
const ENTER_KEY_CODE = 13;
उपयोग कैसे करें?
<form [formGroup]="loginForm" (ngSubmit)="login(loginForm.value)">
<ion-input br-data-dependency="password" type="text" formControlName="username" placeholder="USERNAME" (input)="userNameChanged($event)"></ion-input>
<ion-input id="password" password type="password" formControlName="password" placeholder="PASSWORD"></ion-input>
<button submit-button ion-button type="submit" block>Submit</button>
</form>
आशा है कि यह किसी की मदद करे !!
संपादित करें: मुझे बताएं कि क्या आपको पहले इनपुट बॉक्स के लिए अगला बटन दिखाने के लिए सक्षम किया गया है?
<ion-input type="text" [(ngModel)]="username" (keyup.enter)="handleLogin()"></ion-input>
और::
स्रोत
2017-05-26 09:24:06
आप 'फार्म का उपयोग करने के लिए type =" सबमिट करें "' यह मेरे लिए –