ngFocus在AngularJS中不起作用 [英] ngFocus not working in AngularJS

查看:755
本文介绍了ngFocus在AngularJS中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的代码片段,其中我需要根据复选框值来聚焦输入字段,如果我选中复选框,它应该聚焦第二个元素,它在某种程度上不起作用。让我知道我在Angular中做错了什么。

Following is my code snippet in which I need to focus an input field on the basis of checkbox value, If I check the checkbox it should focus the second element which somehow not working. Let me know what i am doing wrong here with Angular.

注意 - 我已经检查了几个使用指令的例子,但我想知道我在这里缺少什么概念/代码等等

Note - I already checked few examples using directives, but I want to know what I am missing here concept/code etc

<input type="checkbox" ng-model="vm.check" />
<br>
<input type="text" ng-model="vm.input1" />
<input type="text" ng-model="vm.input2" ng-focus="vm.check" />
<input type="text" ng-model="vm.input3" />

Plnkr代码 - http://plnkr.co/edit/q15Jht9AsVj60xrutVfm?p=preview

Plnkr Code - http://plnkr.co/edit/q15Jht9AsVj60xrutVfm?p=preview

推荐答案

ng-focus 用于


指定焦点事件的自定义行为

Specify custom behavior on focus event

不设置焦点。

检查 angular-docs

为了满足您的需求请参阅此处

To meet your case refer here

这篇关于ngFocus在AngularJS中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆