Pre Exam Test Practice (SSC | Banking | IAS | GATE | State Level | CLAT | Railways | Insurance | Teaching Exams | NDA | Defence | IES |State Exam )

Organizational Research By

Surprising Reserch Topic

angular scope watch newval oldval

angular scope watch newval oldval  using -'javascript,angularjs'

I've been working on an angular project I inherited and I can't contact the original author. There is this watch expression I'm not sure of and I was wondering if someone could help me understand the code:

$scope.$watch(calculator.value, function(newVal, oldVal) {
    if(newVal !== oldVal) {
        i = newVal;

What confuses me is this line of code: newVal !== oldVal. Any idea why one would need such a check?

asked Oct 13, 2015 by gauravsinghal83
0 votes

Related Hot Questions

Government Jobs Opening