1
循环遍历ng-repeat很容易,因为您拥有json对象并通过键可以循环和收集数据。 这里我的问题是如何循环通过特定范围或输入来获取包含到ng重复值但未包含到json对象中的值?使用Angularjs循环遍历范围
这里是全码:https://jsfiddle.net/medoo/wgc1my7d/
解释
我有很简单的对象,而像这样的
var arr = ["~\\191746.JPG", "~\\191848.JPG", "~\\191908.JPG"];
键之后,我列出了在结构简单的表作为遵循这些价值观
<div data-ng-app="myApp" data-ng-controller="myCtrl">
<table id="fils">
<tr data-ng-repeat="oneFile in ShowFiles">
<td style="border: 1px solid #000000">{{oneFile}}</td>
<td style="border: 1px solid #000000">
<input data-ng-model="naming" type="text" style="width: 200px" />
<%--here is my problem !!!
i need to get values of element "input" or scope "naming" which not included with ShowFiles --%>
</td>
</tr>
</table>
<input id="save" data-ng-click="save()" type="button" value="Save" />
<div id="msg"></div>
</div>
<script>
var arr = ["~\\191746.JPG", "~\\191848.JPG", "~\\191908.JPG"];
var app = angular.module("myApp", []);
app.controller("myCtrl", function ($scope) {
$scope.ShowFiles = arr;
$scope.save = function() {
var msg = document.getElementById("msg");
var index = 0;
$scope.ShowFiles.forEach(function (oneFile, naming) {
msg.innerHTML =
msg.innerHTML + 'row #' + (index++) + ': ' + JSON.stringify(oneFile) + ' --- ' + naming + '<br />';
});
};
)};
</script>
我所需要的,当我按下按钮#save收集的所有数据,两列是否
(纳入范围“ShowFiles”如{{oneFile}})
OR
(未纳入范围“ShowFiles”这样的为[输入数据-NG-模型= “命名”]) - “这里问题”
要被显示为以下
oneFile ---命名
行#0:“〜\ 191746.JPG“---”动物“
行#1:”〜\ 191848.JPG“--- “汽车总动员”
列#2: “〜\ 191908.JPG” --- “朋友”
但可惜的命名显示这样的0,1,2