[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.

posted @ 2014-11-13 18:08  Zhentiw  阅读(310)  评论(0编辑  收藏  举报