Suppose I have simple Angular2 component
@Component({ selector: \'parent\' })
@View({
template: `
You can use getters and setters to manage it. For your example Child
component must be looked like this:
@Component({
selector: 'child',
properties : ['model']
})
@View({
template: `
<p>Child {{ model }}</p>
`,
})
class Child {
_model: number;
set model(newModelValue) {
// Here we are
console.log('new model value: ' + newModelValue)
this._model = newModelValue;
}
get model() {
return this._model;
}
}
Here is the plunker for your case
You can put your additional logic or calculations into onChange method, that is called after all of component's bound properties are updated.
@Component({
selector: 'child',
properties : ['model']
})
@View({
template: `
<p>Child {{ model }}</p>
`,
})
class Child {
model: number;
onChange(map){
if(map.model) {
console.log('doing crazy stuff here');
console.log(map.model); //SimpleChange {previousValue: 43, currentValue: 44}
}
}
}
Plunker