angularjs - 在 ng-repeat angularjs 中使用文本字段
问题描述
我在 angularjs 中有这样的代码和平:
<div ng-repeat="item in benchmarGeographyObj">
<div style="padding-right: 60px;float:left;">
<input readonly style="width: 100%;" type="text" id="unik" ng-value="item.BEN_BENCHMARK_GEOGRAPHY" />
</div>
</div>
当我尝试在输入文本中添加 ng-model 时出现问题,ng-value 的值消失了,请问我该如何解决这个问题?
解决方案
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.benchmarGeographyObj = [{'BEN_BENCHMARK_GEOGRAPHY': 1},{'BEN_BENCHMARK_GEOGRAPHY': 2}];
});
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>
document.write('<base href="' + document.location + '" />');
</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.3.x" src="//code.angularjs.org/1.3.1/angular.js" data-semver="1.3.1"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
<div ng-repeat="item in benchmarGeographyObj">
<div style="padding-right: 60px;float:left;">
<input readonly style="width: 100%;" type="text" id="unik" ng-model="item.BEN_BENCHMARK_GEOGRAPHY" />
</div>
</div>
</body>
</html>
推荐阅读
- elasticsearch - Grok 自定义模式
- google-apps-script - 如果其他范围内没有任何内容,则在范围内设置值
- unit-testing - 如何在 Golang 测试文件中构建导入
- c# - C# 使用枚举器更改基础数据的值
- python-3.x - 在循环遍历表格数据时使用 Python 创建和检索多维字典?
- gnuplot - 带有 gnuplot 直方图的可变大小的 bin 宽度
- android - 将单选按钮选择从主要活动传递到第二个活动——Kotlin
- python - 如何在不使用 del 的情况下从列表中删除多个元素
- excel - 在短语中搜索单词
- json - UML 如何表示 JSON 文件