Hey there! I've got a scenario where I have an array of people in my dynamic application. Each person, such as James, Bob, and Walter, has their own set of data that needs to be filled out using simple directives.
$scope.users = [
{
name: 'James',
data: []
},
{
name: 'Bob',
data: []
},
{
name: 'Walter',
data: []
}
];
These forms come in the form of $scope.basicDataFormData
and $scope.styleRequestFormData
, which are then attached at the main level like this:
$scope.data = {
basic_data: $scope.basicDataFormData,
style_request: $scope.styleRequestFormData
}
The user's page is determined by $scope.menu.currentIndex
, resetting to
0</code or increasing with each click on "Next user".</p>
<p>However, the problem arises when trying to assign the form data to a specific user. It seems that the forms get copied over to all users instead of being allocated based on the current <code>$scope.data
.
Here's the working example: https://plnkr.co/edit/zGVPViVTkepGB1ZO3PbU?p=preview
As shown in the example, the form data is not assigned correctly to individual users. Instead, all users end up with the same data, even though the index should only correspond to one active user at a time.
Can anyone offer some insight into how to resolve this issue?
The intended functionality is for each form to be saved to the current user's data
object based on the menu.currentIndex
. This way, each user's form data remains persistent within their own view. James should have two objects in his data while Bob and Walter should each have just one.