【问题标题】:angular4 wizard first textfield focus on next stepangular4 向导第一个文本字段专注于下一步
【发布时间】:2018-09-19 00:26:03
【问题描述】:

我已经开发了基于 angular4 的向导,在我有表单的每一步中,在我想专注于第一个文本字段的步骤之间切换,我可以使用 html 属性autofocus 专注于第一步,但只有当页面正在加载,当我在无法获得焦点的步骤之间切换时。

尝试了以下示例,但不幸的是没有成功,

Is there an Angular2 way to focus on an input field?

plunker上创建了一个示例

【问题讨论】:

  • 您能否添加您的研究内容,例如一些代码?这会帮助其他人

标签: angular focus wizard


【解决方案1】:

我已经成功使用了上面链接中描述的方法 (Is there an Angular2 way to focus on an input field?),但我必须将对 focus() 的调用放在 setTimeout() 中:

setTimeout(() => {
   (<HTMLInputElement> this.myInputField.nativeElement).focus();
}, 250);

【讨论】:

  • 我也试过了,但由于我有多个步骤,所以我不喜欢这种方法。
猜你喜欢
  • 2018-01-14
  • 1970-01-01
  • 1970-01-01
  • 2020-07-07
  • 1970-01-01
  • 2017-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多