So, I have here the SSCCE. Essentially, I have a dynamic array of people like so:
$scope.users = [
{
name: 'James',
data: []
},
{
name: 'Bob',
data: []
},
{
name: 'Walter',
data: []
}
];
I have forms that those people need to fill out. Those come in small, simple directives. James has to fill both directive's form, Bob has to fill out one, and Walter has fill out one (but it's the one Bob didn't fill out).
Those forms come in object form like $scope.basicDataFormData and $scope.styleRequestFormData and at the main level, we attach it like so:
$scope.data = {
basic_data: $scope.basicDataFormData,
style_request: $scope.styleRequestFormData
}
At $scope.menu.currentIndex, we govern what user page to show and it is either reset to 0 or increases when you hit Next user.
So, each user's data object, from $scope.users, is based on what the current $scope.data is, right? Wrong.
https://plnkr.co/edit/zGVPViVTkepGB1ZO3PbU?p=preview
As you can see, it doesn't work exactly how it's suppose to. From the example, the form data gets copied over to the next one. And now, both user 1 and user 2 are getting the same exact data when menu.currentIndex is obviously only dictating 1 when next user gets pressed.
Can someone help me out here?
The way it's suppose to work is that all of those forms should only be written to the current user's data object that menu.currentIndex is on. That way, each form is persistant to that user's form view. James should have two objects inside his data while Bob and Walter with only 1.