角复选框,NG-点击 [英] Angular checkbox and ng-click

查看:116
本文介绍了角复选框,NG-点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

角1.2:

<input type="checkbox" ng-model="vm.myChkModel" ng-click="vm.myClick(vm.myChkModel)">

我没有在我的 MyClick认证函数正确的状态呢?

我想要的状态,点击后。

I want the state, after the click.

推荐答案

NG-点击执行 NG-模型<顺序/ code>是模糊的,因为他们没有定义明确的优先事项。相反,你应该使用 NG-变化 $观看 $范围,以确保您获得的正确值的模式的变量。

The order of execution of ng-click and ng-model is ambiguous since they do not define clear priorities. Instead you should use ng-change or a $watch on the $scope to ensure that you obtain the correct values of the model variable.

在你的情况,这应该工作:

In your case, this should work:

<input type="checkbox" ng-model="vm.myChkModel" ng-change="vm.myClick(vm.myChkModel)">

这篇关于角复选框,NG-点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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