Within my MongoDB attributes collection, I am looking to include a new field "odoo_name" for each attribute and save it.
For instance, with 100 attributes, each one will now have an odoo_name field in order to update the existing database.
Issue : when I check console.log(odoo_name), it displays undefined, indicating that it cannot recognize the name entered in the input field.
I modified the ng-submit function to saveOdooNames(vm.localAttributes) and while I am able to retrieve all data, accessing the ng-model still returns undefined. (console.log(inputs.odoo_name)
<form ng-submit="saveOdooNames(i)">
<button>Save</button>
<div class="col-md-12">
<ul class="grid">
<li data-ng-repeat="i in vm.localAttributes">
<label>
<div class="attribute-msl-link-label-wrap">
<div class="attribute-msl-link-label">
<span class="attribute-icon">
<i class="glyphicon glyphicon-folder-open"></i>
</span>
<span class="attribute-number">{{ i.number_id }}</span>
<span class="attribute-title" title="{{i.project.name}}">{{ i.name }}</span>
<input ng-model="i.odoo_name" type="text" class="form-control"/>
<a href="javascript:void(0)" class="del-attr" data-id="{{ i._id}}" data-parent="0">
<i class="glyphicon glyphicon-trash"></i>
</a>
</div>
</div>
</label>
</li>
</ul>
</div>
</form>
This code snippet is from my controller :
$scope.saveOdooNames = function (o) {
var inputs = [];
inputs.push(o);
$http({
method: 'POST',
format: 'json',
url: '/api/odoonames',
headers: {
'Content-Type': 'application/json'
},
data: { _id : inputs._id,
odoo_name : inputs.odoo_name }
}).then(function (success) {
console.log('Success ' + JSON.stringify(success));
}, function (error) {
console.error("Error " + JSON.stringify(error));
});
};
Note: Saving fields individually works fine, but I require a bulk save for these fields.
EDIT :
I changed ng-submit="saveOdooNames(i)"
to ng-submit=vm.localAttributes)"
End Edit
The Save button should store all input data in an Array named "inputs"