问题标签 [angularjs-ng-checked]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
44 浏览

javascript - 无法在 ng-checked 函数中获取传递的参数

我在 ng-checked 中调用了一个函数来检查当前复选框的值是否为“test”,如果选中,则应选中该复选框,否则应取消选中该复选框

为了实现这一点,我将 this.value 作为参数传递给在 ng-checked 中调用的 show 函数。但是this.value登录控制台时这是未定义的。即使我将函数内部的事件对象作为参数传递,它也会返回未定义。

请检查以下代码:

提前致谢 :)

0 投票
1 回答
136 浏览

angularjs - 使用 ng-repeat 进行 Ng-Checked 而不在 angularjs 中使用 for 循环

任何人都可以帮助弄清楚 ng-checked

如果我使用 for 循环,这项工作。但我不想使用循环。有没有其他方法可以帮助任何人。我尝试使用 ng-change、ng-click 但仍然没有工作。

0 投票
1 回答
272 浏览

javascript - How to set checkbox ng-checked from server data using AngularJS and save the checked/unchecked back to server data?

This should be a very common problem, invoking an ng-model to parse the data into form (DOM) after which the modified checkbox's ng-checked will be translated back to data values so to be saved back on the server.

I have two check boxes respectively

And, my data is

My objective is :
I want a straight-forward easy way (easy-to-maintain codewise, which is, angularJS ng-model) to set the checkboxes CHECKED/UNCHECKED by the data read from the server. Also, I want to be able to save the values represented by CHECKED/UNCHECKED to the data just as it came.

0 投票
1 回答
39 浏览

javascript - 预先检查的输入框没有被序列化

我有一个简单的代码,列出了许多颜色,并检查用户是否预先选择了一些颜色(这是在代码上设置的,但实际上它来自数据库)。当我提交表单时,预先检查的输入不会列在数组中,如果我取消选中一些,这不会从数组中删除。