angularjs - 从引导模式中的 ng-repeat 输入获取 ng-model 值
问题描述
我需要使用 ng-repeat 显示数组中的一些数据,并且每个数据都有自己的输入字段。我需要动态附加这些输入,然后通过调用函数从它们获取数据。
//controller for my modal
app.controller('myCtrl1', function($uibModal, $uibModalInstance,
$window, $http, data) {
var pc = this;
pc.childTradeValues = data.childTradeVal.child;
pc.arr = [];
pc.confirmTrade = function (object) { //Confirm Trade Function
console.log(object);
// $uibModalInstance.close();
};
pc.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
});
//Code of my Modal where im creating inputs
<div class="modal-body">
<div>
<div ng-repeat="childTradeValue in pc.childTradeValues track by $index">
<label>{{ childTradeValue.email }}</label>
<input type="number" ng-model="arr[$index]" class="form-control" placeholder="Enter Quantity">{{arr[$index]}}
</div>
</div>
</div>
<div class="modal-footer">
<div class="col-md-12 textAlignCenter">
<button class="btn btn-success" ng-click="pc.confirmTrade($index)">
Confirm
</button>
</div>
//my Array
$scope.childTradeVal = {"child":[{"id":1,"email":"test@gmail.com"},
{"id":2,"email":"test2@gmail.com"},
{"id":3,"email":"test3@gmail.com"}]};
解决方案
推荐阅读
- django - Django SyntaxError:无效的语法“else”语句?
- c# - 更新标签每个 Web 浏览器使用 c# 在特定时间刷新
- sql - 如何在 SQL 中创建此视图
- reactjs - React-router-v4 默认路由不适用于 Express 后端
- javascript - IBM Watson Visual Recognition API、Node.js:未经授权:由于凭据无效,访问被拒绝
- java - 通过显式 SSL/TLS 在 FTP 上登录成功,但无法浏览文件
- html - 如何对齐水平项目?
- matlab - “parfor 中的变量无法分类”MATLAB
- php - 基于 Laravel 5.6 中的年份和值的自动编号
- css - Mini-css-extract-plugin - 如何掌握 index.html 上的哈希命名