I built a csv contact importer using Papaparse. The site runs on angular.
This is my form:
<div ng-show="import_file_selected">
<form ng-submit="processImport()" name="importForm">
<div class="row">
<div class="col-md-12">
<table class="table table-hover">
<tr>
<th ng-show="has_header" class="col-md-4">Header</th>
<th class="col-md-4">Attribute</th>
<th class="col-md-4">Value Sample</th>
</tr>
<tr ng-repeat="row in rows">
<td ng-show="has_header">{{row.header}}</td>
<td>
<select class="form-control" name="{{row.header}}">
<option value="">Ignore</option>
<option ng-repeat="attribute in attributes" value="{{attribute.key}}">{{attribute.val}}</option>
<option value="add">Add Attribute</option>
</select>
</td>
<td>{{row.values}}</td>
</tr>
</table>
</div>
</div>
<div class="row">
<div class="col-md-6 form-group col-md-offset-3">
<button class="btn btn-primary btn-block" type="submit">Save Import</button>
</div>
</div>
</form>
</div>
The HTML gives this result:
So far, this all functions and displays correctly. However, I have no idea how to capture the data in my processImport()
function.
I thought of using binding, but since a user can add/remove attributes from the select box, I can't pre-build the select box. And since each csv can have a different number of columns, I need to repeat with each column there is.
Any suggestions on how I can capture the data submitted here? Please let me know if I should add anything else.