I have an application where i have checkboxes for each item(configurations) from an array(configurationsArray). What i want to implement is to add the configuration to the cookie store when checkbox is checked
Here is my code
$scope.addProjectConfig = function(configuration, projectName) {
var configs = $cookieStore.get('projectsToCompare');
if(!configs) {
$cookieStore.put('projectsToCompare', new Array());
configs = $cookieStore.get('projectsToCompare');
}
if(configuration.addedToCompare) {
var configObject = {projectName: projectName, configuration: configuration};
configs.push(configObject);
$cookieStore.put('projectsToCompare', configs);
}
var configs1 = $cookieStore.get('projectsToCompare');
};
If you see in the end i try to get the stuff i pushed in the cookieStore and it works fine.
However when another checkbox is checked and the method gets executed again, i see that the value returned in the beginning has an empty array. What am i doing wrong here? Any pointers are deeply appreciated.