- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面是HTML内容
<label ng-repeat="(index, item) in field.optionValue">
<input type="checkbox"
checklist-model="formControlsValues[dbColumnName]"
checklist-value="item">{{field.optionName[index]}}
</label>
field.optionValue 和 field.optionName 是一个数组
field = { optionValue : ["1","2","3"], optionName : ["xxx", "yyy", "zzz"] }
checklist-model,formControlsValues[dbColumnName]是一个动态对象模型,预计在勾选/选中复选框时填充值。
在渲染过程中,formControlsValues[dbColumnName] 将是 Controller 中的 $scope.formControlsValues.Village 或 $scope.formControlsValues.State ,并预计以下面提到的格式填充$scope.formControlsValues.Village = ["2","1"]
最佳答案
这是工作代码。我想指出的是,您必须将数字作为数字而不是字符串(带双引号)获取,因为您可能会在将来出现问题。
// Code goes here
var app = angular.module('checkList', ["checklist-model"]);
app.controller('checkListCtrl', function ($scope) {
$scope.formControlsValues = {};
$scope.field = {
optionValue : ["1","2","3"],
optionName : ["xxx", "yyy", "zzz"],
dbColumnName : "State"
};
$scope.dbColumns = ['State', 'Village'];
$scope.formControlsValues = {
Village : [],
State : []
}
});
<!DOCTYPE html>
<html ng-app="checkList">
<head>
<script data-require="angular.js@1.6.0" data-semver="1.6.0" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.0/angular.js"></script>
<script data-require="checklist-model.js@*" data-semver="0.0.1" src="http://vitalets.github.io/checklist-model/checklist-model.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body ng-controller="checkListCtrl">
<h4>Checklist model</h4>
<div>
<label ng-repeat="(index, item) in field.optionValue">
<input type="checkbox"
checklist-model="formControlsValues[field.dbColumnName]"
checklist-value="item">{{field.optionName[index]}}
</label>
</div>
<br />
<div>
<select ng-model="field.dbColumnName" ng-options="d for d in dbColumns"></select>
</div>
<div>
<label>Selected Villages: {{formControlsValues.Village}}</label>
</div>
<div>
<label>Selected States: {{formControlsValues.State}}</label>
</div>
</body>
</html>
关于javascript - checklist-model 和 checklist-value 未更新模型或未按预期运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41893309/
下面是HTML内容 {{field.optionName[index]}} field.optionValue 和 field.optionName 是一个数组
我正在使用 Core Data 来离线存储我的 iOS 应用程序,但我不断收到以下错误: Illegal attempt to establish a relationship 'checklists
我正在研究以下 linux 对话框。我无法理解它的行为。这可以正常工作,即正确显示三个复选框。 #!/bin/sh dialog --backtitle "Test" \ --title "Check
我目前正在从事一个大学项目,我们在其中使用 Fluent NHibernate。我正在研究如何为我们的实体和 Fluent 映射创建测试。 但是,我在尝试弄清楚如何使用 PersistenceSpec
当我尝试运行我的应用程序时,它突然显示类没有初始化程序的错误。告诉我他们是否有任何代码问题或变量声明问题。任何人都可以告诉我此错误背后的原因。 import UIKit class Checklist
嘿 Stackoverflow 的 super 英雄。我目前正在使用 angularjs 和 checklist-model 指令制作 list 。我试图弄清楚当达到 x 数量的选中框时如何禁用所有未
我迷失了获取 bash 对话框的返回值。问题是:如何获取 --checklist 的返回值?这是一个多项选择列表,我需要每个项目的返回值。这是代码: dialog --checklist "packa
这个问题在这里已经有了答案: 关闭 11 年前。 Possible Duplicate: What are all the common undefined behaviour that a C++
我正在使用 linux 实用程序对话框(见下文)创建一个菜单,我听说可以为这些 list 创建一个树状结构。但是我在联机帮助页中找不到任何类型来创建这样的东西?真的有可能吗——如果有的话:怎么办?参见
我已经学习java大约3天了,但我似乎无法将数据附加到我的ArrayLists( list )之一。尝试显示数组内的所有项目时的输出始终为 []。非常感谢您的帮助! ShopAssist.java:
我正在尝试使用 persistence specification testing内置于 FNH。 CheckList 方法似乎是最近添加的,但是旧的 CheckEnumerable 已经被弃用,所以
我在 ng-repeat 循环内选中了复选框,并使用 checklist-model 来获取选中的值。但是我需要将这些复选框设置为默认选中。我使用过ng-checked="true"。但是它显示复选框
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 3 年前。
我正在编写一个程序来寻找从 1,000,000 开始的最长 Collatz 序列。 我真的为这段代码感到自豪,它看起来如此高效、干净、写得很好……直到我尝试运行它。经过一些调试使其能够编译后,我发
是否有一种方法可以灵活地根据所选环境选择要部署代码的主机子集?旁注:这不是发布管道 获取环境参数值 pipeline.yml parameters: - name: env displayNa
我试图在我的应用程序中使用 [checklist-model] ( https://github.com/vitalets/checklist-model ) 模块,但我发现了一个错误,我发现这是因为
是否有一种方法可以灵活地根据所选环境选择要部署代码的主机子集?旁注:这不是发布管道 获取环境参数值 pipeline.yml parameters: - name: env displayNa
我是一个 Node.js/grunt 世界的菜鸟,所以如果这个问题很愚蠢,我很抱歉...... 我有一个与 yeoman/grunt 一起使用的 angular.js 项目,现在我想做的是包含一个指令
我有两个 list : List list1 = new List(){ "a", "b", "c", "d" }; List list2 = new List(){ "b", "d", "e" }
我有一个小表格,有 2 个日期输入和一个 list ,它们都是复选框。我无法弄清楚如何需要列表中的任何一个复选框来进行表单验证。如果我为一个复选框添加 ng-required ,它会对所有复选框重复。
我是一名优秀的程序员,十分优秀!