问题标签 [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 回答
1126 浏览

javascript - 当我关闭模式时,选中的输入变为未选中

我使用复选框类型的输入来缩小我的搜索结果;问题是我将复选框放入模式中,当我选中其中许多并关闭模式时,选中的输入变为未选中。

我希望每次打开检查的模态输入时都被检查。

我想知道有什么方法可以存储检查的输入并使用模态将它们带回检查状态?TNKS 很多

0 投票
1 回答
1031 浏览

javascript - AngularJS:ngChecked 不起作用

我有以下单选按钮:

我已经仔细检查poll_post.poll_option_id并且option.id是平等的。所以 ng-checked 中的表达式被评估为 true。但是在视图中,该选项没有被选中。我究竟做错了什么?

0 投票
3 回答
201 浏览

javascript - 在 ng-checked 上,我需要显示 div 内的数据

我有一个行数为“n”的表,每行都有一个复选框。选择复选框后,我试图显示<div>标签内编码的信息。

但是即使复选框的值是假的,仍然会显示 div 内的数据,我在 div 标签中使用 ng-show 来检查复选框是真还是假。

以下是我在表格列中使用的代码:

在 JavaScript 中,我有以下切换功能

按索引切换给定行项目的选择

如果我做错了,请指出我,我对角度世界很陌生。

0 投票
0 回答
709 浏览

angularjs - 多个 ng-repeat 中的多个输入无线电不会被 ng-checked 检查

我正在创建一个表格,其中每个单元格都有多个单选按钮。

看截图:

在此处输入图像描述

我正在动态创建选项,我想根据我手头的数据检查每个单元格的单选按钮。

我正在做的是向每个收音机询问单选按钮组的当前值

但是只有最后一个单元格上的选项被选中,第一个单元格未被选中,即使在 htmlchecked=checked中正确输入时也是如此。

我创建了一个带有演示的 plnkr,我遇到了同样的问题。

http://plnkr.co/edit/0QF1ihd6NQsqAM6LMxK0?p=preview

0 投票
1 回答
657 浏览

angularjs - 在使用 ng-repeat 时,如果另一个角度数组中存在一个值,如何将 ng-checked 设置为 true?

// 已分配区域的数组

// 所有地区的数组

//HTML

如何制作类似于 checkAlreadyAssigned(list.districtId) 的函数。此函数应获取地区 ID 并检查此地区 ID 是否存在于 already_assigned 数组中,如果是则返回 true 或返回 false。请。

0 投票
2 回答
2883 浏览

javascript - 如何根据父母检查所有孩子,同时根据孩子检查父母?

Plnkr:https ://plnkr.co/edit/Tt96EE2rruy1HAudRVJR?p=preview

我有以下嵌套的复选框循环:

这是检测 ($watch) 是否已选中部分或所有子复选框的代码,如果是,则父复选框也会被选中。

这很好用。

但是,当我检查父框时,它不会检查。

我想要实现的是,当我选中父复选框时,它的所有子复选框也会被选中,当我取消选中父复选框时,它的所有子复选框都会被选中。

0 投票
4 回答
1155 浏览

javascript - 从 ngRepeat 选中复选框时填充输入

我正在尝试以两种方式填充输入。第一种方法是简单地在输入中输入一个金额,这非常有效。第二种方法(我正在努力)是检查 ngRepeat 指令中生成的复选框。

所需的行为是复选框将从 JSON 数据中获取 item.amount 的值,并使用该值填充输入。这是标记:

这是JavaScript:

0 投票
0 回答
453 浏览

javascript - ng-checked/ng-model prevent change to model when user clicks checkbox

I'm building a simple form with a toggle. I want to bind the toggle to my model, welcomeEmail.welcome_email_on. When I click the toggle, I want to call toggleWelcomeEmail() in my controller. This function will check if the new state is true or false and then do something. For example, if the toggle was off, and the user clicks it, it should turn on. If it is already on, and the user clicks it, the toggleWelcomeEmail() function should display a confirmation prompt and the toggle should remain on until the user confirms the action in the prompt.

The problem I'm having is that it seems the default behavior of ng-model and ng-checked on a checkbox is to update the model when the user clicks the checkbox. What I want to do is prevent the default. I want the state of my checkbox/toggle to reflect the model, however I do not want the model to update when it is clicked. Instead I prefer to call toggleWelcomeEmail().

My question is, how can I accomplish this? I've tried using both ng-checked and ng-model, but both behave the same way. I know I could create two toggles and just show/hide them based off the state of welcomeEmail.welcome_email_on, but then I'd loose the nice toggle animation I have. I've also tried the obvious approach of putting an $event.stopPropagation() on my ng-click action, however that had no effect.

I've created a fiddle to demonstrate the problem.

0 投票
1 回答
42 浏览

angularjs - angularjs - 从远程数据控制复选框状态

我正在尝试制作通知配置页面。基本上,用户应该能够选择他希望接收特定模块的通知类型。有 3 种类型的通知(电子邮件、SMS 和 UI)。目前我的阵列是这样构建的

我正在努力实现这个观点

在此处输入图像描述

问题:当我尝试重复某个模块的通知时,如果例如 {"notification": "email"} 不存在,则复选框不会保持未选中状态,而是从视图中删除。

任何想法如何执行 ng-repeat?谢谢

JSFiddle

0 投票
1 回答
1784 浏览

angularjs - 选中条件下的单选按钮

我有这样的结构

  1. 我选择雇主作为当前。
  2. 我继续添加新雇主。
  3. 在新雇主单选按钮中,它应该默认选择为单选按钮“上一个”

我试着在这样的条件下工作。如果有人可以请帮助检查动态创建的单选按钮的条件!

谢谢