Angular 1.5 component onChanges is not working

Since we have pretty big Angular 1.x application, we can’t upgrade it fully to Angular 2 but I love the new architecture. Version 1.5 brings amazing components to the old same app. As all cool stuff, it lacks documentation 😉

So, here is a question. I have those two lines in the controller’s definition:

this.$onInit = setType;
this.$onChanges = setType;

the first is working, whilst the second isn’t. I am using '<' binding. So on the first load, the component’s state is set according to passed values, whilst the changes are not being reflected. I got the hope that it should work from [1] and [2].

[1] https://docs.angularjs.org/guide/component

[2] https://angular.io/docs/js/latest/api/core/OnChanges-interface.html

UPD Ok, I have learnt that it is not supposed to work:
https://github.com/angular/angular.js/issues/14030

Does anybody know good workarounds?

UPD2 It works as of 1.5.3

20 thoughts on “Angular 1.5 component onChanges is not working”

Leave a Comment