Hi there, I'm facing a challenge with updating an object that has child properties in my Angular application.
Here is the initial object:
$scope.osbStep = {
test0Nav : {
current : false,
complete : false,
hidden : false
},test1Nav : {
current : false,
complete : false,
hidden : false
},test2Nav : {
current : false,
complete : false,
hidden : false
},
};
The object to broadcast:
var currentPage = { test0Nav : { current : true }};
$rootScope.$broadcast('step:set', currentPage);
Any ideas on how to update object 1 with object 2?
I've been trying to match properties by looping through them, but I'm struggling to update object 1 with the data from object 2. My logs only show strings.
$scope.$on('step:set', function( event, currentStepData ){
for ( var key in currentStepData ) {
if( currentStepData.hasOwnProperty( key ) ) {
var currentKey = key;
for ( var foo in $scope.osbStep ) {
if( $scope.osbStep.hasOwnProperty( foo ) ) {
if (currentKey === foo){
console.log( 'foo ', foo );
console.log( 'currentKey 'currentKey );
}
}
}
}
}
});