One of the challenges I am facing involves watching a value in one controller that is changed in another controller within my filters. The goal is to determine whether an emit should be triggered based on the updated value. Here's the current situation:
scope.$on('XChanged', function(event, x) {
console.error( '==order list has changed : ' + x );
console.warn('INSIDE FILTER ON '+event);
scope.bx = true; // The variable bx is initialized in the calling controller and defaults to false.
});
console.warn('AFTER FILTER ON 1 >>'+ scope.bx);
if( !scope.bx ){
scope.$emit('handleEmit', {msg: 'RECYCLE' });
console.error( scope.bx+ ' Recycle requested. ');
}
The issue at hand is that the scope.on code executes first and does not follow a top-to-bottom flow within the filter. Furthermore, even after setting bx to true in scope.on, the condition if( !scope.bx )
evaluates as true. This indicates that the assigned true value to bx is not properly set... suggesting that there might be an error in my approach. Can you provide guidance on how to rectify this? Essentially, I need to ensure that the emit is only executed based on the updated value of bx from scope.on.