Check out this pen to see what I'm working on and the issue I'm facing: http://codepen.io/Irish1/pen/lbjdw
I've been working on a program that involves adding a week object, where I can input the name of the week along with a description. However, when I try to add a day to the week, it ends up clearing out the previously entered name and description. This issue only occurs when adding a day for the first time, and I suspect it has something to do with the logic in the ELSE path of my add day method in the controller function below:
$scope.addDay = function(index) {
if (isDefined($scope.program.weeks[index].days)) {
$scope.program.weeks[index].days.push(
{
}
);
} else {
$scope.program.weeks[index] = {
days: [
{
}
]
};
}
};
You can find the complete code in the pen linked above. Any insights on how I can add the first days object without overwriting existing data in the weeks object?