I have the following array of objects:
$scope.users = [
{
ID: "1",
Name: "Hege",
Username: "Pege",
Password: "hp",
},
{
ID: "2",
Name: "Peter",
Username: "Pan",
Password: "pp"
}
];
I need to create a similar object with empty values like this,
$scope.newUser = {
ID: "",
Name: "",
Username: "",
Password: ""
}
so that I can push it to the same array ($scope.users.push($scope.newUser);), to get it look something like this:
$scope.users = [
{
ID: "1",
Name: "Hege",
Username: "Pege",
Password: "hp"
},
{
ID: "2",
Name: "Peter",
Username: "Pan",
Password: "pp"
},
{
ID: "",
Name: "",
Username: "",
Password: ""
}
];
However, the array $scope.users will not always have the array of same objects. I need it to work even if I change the array to something different, for example, like this:
$scope.users = [
{
SID: "pepe",
Name: "Peter",
School: "Primary School"
},
{
SID: "hepe",
Name: "Hege",
School: "Junior School"
}
];
How can I do this?