I have this code that I'm using to organize the staff members in company1, but it seems to be creating a new list of arrays. Can someone assist me with this issue?
Once I add the name and ID of the staff, the array will appear as follows:
[{companyName: "company1", companyAddress: "company address", staff: [{name:"men", id: "123"}, {name:"boy", id: "1343"}, {name:"john", id: "145"}]}]
<div ng-controller="MyCtrl">
<input type="text" ng-model="nameStaff" />
<input type="text" ng-model="idStaff" />
<button ng-click=addDetail()>add</button>
{{form}}
</div>
var myApp = angular.module('myApp', []);
function MyCtrl($scope) {
$scope.form = [{ companyName: "company1", companyAddress: "company address", staff: [{ name: "men", id: "123" }] }];
$scope.addDetail = function() {
$scope.form.push({ staff: [{ name: $scope.nameStaff, id: $scope.idStaff }] });
}
}