In the following snippet:
angular.module('myModule')
.component('myComponent', {
controller : [
MyComponentController
],
bindings: {
input: '<'
}
});
According to documentation - section "Components have a well-defined lifecycle" in order to monitor that the binding input
has changed we could use $onChanges
lifecycle method. I can't make it work.
Thi is how I am using it:
function MyComponentController() { self.$onChanges = function (changesObj){ // some code here } }
But the code doesn't even enter the fuction.
As we figured out in the comments, the issue was that the $onChanges
hook (along with $onDestroy
and $postLink
) was not added until version 1.5.3 of Angular, and zatziky was using 1.5.0, which only implements the $onInit
hook. Seems a bit strange for them to add such a big feature in a patch level release, but at least it was an easy fix.