Added check about phase state of $rootScope to prevent error occuring when $scope.$apply() is invoked during validation.