Angularjs输入字段焦点事件? [英] Angularjs input field focus event?

查看:283
本文介绍了Angularjs输入字段焦点事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用angularjs和我创建了一个正常的输入字段是这样的:

i use angularjs and i have created a normal input field like this:

<input type="text" style="border: none" ng-model="model" >

我要做到以下几点:

i want do the following:

如果有人点击输入领域,我想呼吁实例方法A.然后,他在这一领域的写入文本,如果该人点击某处我的网页,这样的输入域不再关注它应该调用方法B.这可能与angularjs?如果是的话,我怎么能做到这一点?
NG-焦点只在输入事件而不是在输出有效。

if someone clicks in the input field, i want call for example method A. Then he writes text in this field and if the person clicks somewhere in my page so that the input field is no longer focused it should call method B. is this possible with angularjs ? if yes, how can i do that ? ng-focus is only active at the input event but not at the output..

我要锁定这个东西,方法的设置只有值为true和方法B将相同的值设置为false。但我必须知道,当输入字段处于激活状态时没有。

i want lock something with this, method A sets only a value to true and method B sets the same value to false. but i must know when the input field is active and when not.

推荐答案

您正在寻找 NG-焦 NG-模糊

You are looking at ng-focus and ng-blur.

<input type="text" style="border: none" ng-model="model" ng-focus="A()" ng-blur="B()">

在一个侧面说明,使用CSS类,而不是内嵌样式..:)

On a side note, use css classes instead of inline styles.. :)

或者只是调用带有参数同样的方法设置的值ACC: -

Or just call the same method with argument and set the value acc:-

 <input type="text" style="border: none" ng-model="model" ng-focus="A(true)" ng-blur="A(false)">

这篇关于Angularjs输入字段焦点事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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