My challenge involves an array containing arrays and objects. Within a function, I am attempting to assign a value to a specific property (for example, setting 'call' of $scope.companies[0].users to the value selected in a checkbox). Despite my research efforts, I have been unsuccessful in achieving this task and everything I have attempted so far has been incorrect. Any help would be greatly appreciated!
<form action="" ng-click="change(key)">
<input ng-model="key.call"type="checkbox"">Call
<br>
<input ng-model="key.person"type="checkbox" >Person
<br>
<input type="checkbox"ng-model="key.dial">Dial
<br>
<input type="checkbox" ng-model="key.voice">Voice
</form>
app.controller('appCtrl', function($scope) {
$scope.companies = [{
name: 'The Best Company Denim',
users: [{
firstName: 'Alex',
lastName: 'D',
number: 1234,
call: '',
person: '',
dial: '',
voice: ''
}, {
firstName: 'Sarah',
lastName: 't',
number: 14,
call: '',
person: '',
dial: '',
voice: ''
}, {
firstName: 'J',
lastName: 'd',
number: 07,
call: '',
person: '',
dial: '',
voice: ''
}]
}, {
name: 'The Best Company Elegant',
users: [{
firstName: 'Alx',
lastName: 'B',
number: 1234,
call: '',
person: '',
dial: '',
voice: ''
}, {
firstName: 'Seth',
lastName: 'w',
number: 12,
call: '',
person: '',
dial: '',
voice: ''
}, {
firstName: 'J.S',
lastName: 'B',
number: 7.
call: '',
person: '',
dial: '',
voice: ''
}]
}, {
name: 'The Best Company by Julia',
users: [{
firstName: 'Aleddddx',
lastName: 'l',
number: 1234,
call: '',
person: '',
dial: '',
voice: ''
}, {
firstName: 'Maggy',
lastName: 'n',
number: 1,
call: '',
person: '',
dial: '',
voice: ''
}, {
firstName: 'Ja',
lastName: 'Key',
number: 123,
call: '',
person: '',
dial: '',
voice: ''
}]
}]
$scope.change = function(key) {
for (var i = 0; i < $scope.companies[0].users; i++) {
$scope.companies[0].users[i].call: key)
}
}
});