找出它是否被点击之前无线电选项被选中 [英] Find out if radio option is checked before it was clicked

查看:114
本文介绍了找出它是否被点击之前无线电选项被选中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下单选组。

<input type="radio" name="GROUP1" ng-checked="true" ng-model="group1" id="name1" value="one">
<input type="radio" name="GROUP1" ng-checked="false" ng-model="group1" id="name2" value="two">
<input type="radio" name="GROUP1" ng-checked="false" ng-model="group1" id="name3" value="three">

当点击一个无线电投入,我希望能够,如果要弄清楚,在单击它之前,如果它最初激活。

When a radio input is clicked, I want to be able to figure out if, before it was clicked, if it originally active or not.

例如,如果我点击#名称1 ,它会因为它已经签回响应正确的。

For example, if I clicked on #name1, it would respond back true because it was already checked.

如果我点击#NAME3 ,因为#名称1 最初选择它会回应回假。但如果我点击#NAME3 再次,它将返回回真。

If I clicked on #name3, it would respond back false because #name1 was originally selected. But if I click on #name3 again, it would return back true.

谁能帮我这个?

推荐答案

您可以看在你的控制器此code。
现在,只要你的模型将被改变(在UI或控制器),本次活动将提高。

You can watch this code in your controller. Now, whenever your model will be changed(in the ui or in the controller), this event will be raised.

$scope.$watch('group1', function (newValue, oldValue) {
   //Place your code here ...
   // You have access to the old and to the new Value
});

只是为了您的信息,请尝试使用至少手表,你可以...

Just for your information, try to use at least watches as you can...

这篇关于找出它是否被点击之前无线电选项被选中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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