mtpultz mtpultz - 2 years ago 1329
AngularJS Question

AngularJS 1.5.x $onChanges Not Working with One-Way Binding Changes

I don't understand why $onChanges isn't kicked off when I change a bound primitive in an input. Can someone see what I've done wrong, and explain this in an uncomplicated way? I made a plunkr of a quick test application after I couldn't get it to work in my actual application either.

.module('test', [])
.component('test', {

template: '<child application="vm.application"></child>',
controller: 'testCtrl as vm'
.controller('testCtrl', function() {

var vm = this;

vm.$onInit = function () {

vm.application = {
data: {
name: 'Test'
.component('child', {

template: '<input type="text" ng-model="">',
bindings: {
application: '<'
controller: 'childCtrl as vm'
.controller('childCtrl', function() {

var vm = this;

vm.$onChanges = function (changes) {
console.log('CHANGED: ', changes);

Answer Source

It's $onChanges and not $onChange.

Also, the onChange only updates when the parent value is changed, not the child. Take a look at this plunkr. Note the console.log only fires when you type in the first input.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download