角度:点击事件在移动设备上不起作用

时间:2019-04-19 03:32:10

标签: angular button mobile click

单击事件在移动设备(Ipad和Samsung手机)上不起作用。页面被重定向到正确的路由,但它为空白。当我按Enter键时,它可以工作。

这是html格式:

<form #myForm>
          <div class="form-group">
              <div class="input-group col-md-10">
                  <select class="form-control col-md-4" [(ngModel)]="selected" (ngModelChange)="languageSelected($event)" [ngModelOptions]="{standalone: true}">
                      <option *ngFor="let option of options" [value]="option.id">{{option.value}}</option>
                  </select>

                  <input type="text" class="form-control" #elem (keyup)="onNameKeyUp(elem.value)"
                  [ngModelOptions]="{standalone: true}"
                  [(ngModel)]="latinButton"
                  (focus)="onNameKeyUp(elem.value)"
                  placeholder="Enter"/>


                  <span class="input-group-append">
                      <button class="btn btn-outline-secondary" type="submit" (click)="getWordList(elem.value)">
                          <i class="fa fa-search"></i>
                      </button>
                    </span>


                  </div>
              </div>
              </form>

此onNameKeyUp函数:

onNameKeyUp(event: any){
      this.spelling = event;
      this.spelling = this.spelling.toString().toLowerCase();
      this.elem.nativeElement.focus(); 

  }

编辑:我正在添加getWordList()函数:

 getWordList(name: string){

    this.spelling = name;
    this.webservice.getWords(this.spelling, this.selected)
    .subscribe((res: Array<Word>)=> {
      this.elements = res.filter(d=> d.orth == this.spelling || d.asuddimIsem == this.spelling);
      this.grammar = res[0]['gram'];
      this.dataLoaded.emit(this.elements);
      this.webservice.setData(this.elements);
      this.router.navigate(['/words']);
    })
  }

0 个答案:

没有答案
相关问题