In app.component.ts, I have a property called current.
export class appComponent {
current = 0;
}
In some of my methods I changed this property
previous() {
this.current -= 1
}
next() {
this.current += 1
}
Now, I want to run a set of command when current property is changed. I can do it by appending those command after changes.
previous() {
this.current -= 1;
this.runCommands();
}
next() {
this.current += 1;
this.runCommands();
}
Everything works just fine. But see, it seems very messy calling this method every time this property changes. What I want to do run a change detection function what run my command like:
this.current.valueChanges.subscribe(() => this.runCommand());
is it possible with any simpler way in angular?
Thanks in advance