When in my controller I change my array, with a "push" or "pop", angular doesn't detect that has changed and doesn't fire "this.$OnChanges " on my controller component. However if I change directly the array, it does. I don't know if it's a bug or operation is correct.
This is expected behavior. From the docs (emphasis mine):
one-way binding watches changes to the identity of the parent value. That means the
$watchon the parent value only fires if the reference to the value has changed. In most cases, this should not be of concern, but can be important to know if you one-way bind to an object, and then replace that object in the isolated scope. If you now change a property of the object in your parent scope, the change will not be propagated to the isolated scope, because the identity of the object on the parent scope has not changed. Instead you must assign a new object.
Thank you @gkalpak !!
thanks for the information!
What is the way to invoke $onchanges or any similar method on change of array variables?
You can't have AngularJS automatically detect such changes for you. You can use the $doCheck() hook to manually check the values you are interested in or use $watchCollection() (or a deep $watch). Note that these kind of checks result in worse performance that just having to check for object reference change.
Most helpful comment
This is expected behavior. From the docs (emphasis mine):