I might be overthinking this, but that's why I'm seeking help. :)
Note: In the example below, the controller alias for the component is "ctrl". var ctrl = this;
Imagine we have a component with two bindings, one of which is optional:
bindings: {
params: '<',
company: '<?'
}
Sometimes the company binding is present, and sometimes it's not.
The $onChanges function looks like this:
ctrl.$onChanges = function(changes) {
if (changes.params || changes.company) {
console.log('executed');
}
}
It appears that when both bindings are updated, $onChanges is triggered twice. The first time, the value of ctrl.company (the binding) in the component is null, even though I updated it with a value. The second time, ctrl.company does have its value.
It's possible that the OR operation in the conditional is not correct. I'm just not entirely sure how $onChanges works.
I'll provide more clarity if my explanation of the issue is confusing.
Thank you in advance.