Newbie : should I use $watch or ng-change, to detect onchange on a range input and process according to the value


#1

Hi,

firstly, I am new to Ionic !

I am trying to detect the change of value of a range input, and to act upon it depending on the value.

But I am not sure how to detect it : $watch or ng-change ?

Here’s the code pen with both


#2

I have always used ng-change, and I would always recommend it over a watch; if you use a watch you will need to check that the old value does not equal the new value before undertaking the required action. I also feel that it makes your code neater as you don’t need to declare anything in your $Destory to ensure your watch is cleared down correctly.


#3

Thanks for your help n40jpj