[AngularJS] AngularJS 1.3 $scope.$watchGroup

$watchGroup can monitor an array or expression.

We watch both email and password by using the same callback function.

    $scope.$watchGroup(['user.email', 'user.password'], function(newVal, oldVal){
        console.log(newVal, oldVal);
    });

One thing need to be noticed that, for input type="email", unless you type '@', the $watch won't get fired.

And also, for init, the value would be undefined.

原文地址:https://www.cnblogs.com/Answer1215/p/4095590.html