angular / angular-hint

run-time hinting for AngularJS applications
362 stars 45 forks source link

humanReadableWatchExpression error on app load #94

Open gary-b opened 9 years ago

gary-b commented 9 years ago

When http://citiesinmotion.iese.edu/indicecim/ (Angular v1.2.16) is debugged with Batarang the console shows the following error message on load:

"TypeError: Cannot read property 'exp' of null
at humanReadableWatchExpression (chrome-extension://ighdmehidhipcmcojjgiloacoafjmpfk/dist/hint.js:2062)
at Scope.scopePrototype.$watch (chrome-extension://ighdmehidhipcmcojjgiloacoafjmpfk/dist/hint.js:1840)
at new paisesCtrl (/indicecim/scripts/views/app.js:180)
at invoke (/indicecim/scripts/vendor/angular/angular.js:3870)
at Object.instantiate (/indicecim/scripts/vendor/angular/angular.js:3881)
at /indicecim/scripts/vendor/angular/angular.js:7135
at chrome-extension://ighdmehidhipcmcojjgiloacoafjmpfk/dist/hint.js:1538
at /indicecim/scripts/vendor/angular/angular.js:6539
at forEach (/indicecim/scripts/vendor/angular/angular.js:331)
at nodeLinkFn (/indicecim/scripts/vendor/angular/angular.js:6526)"

The app then does not load properly. (Result of some testing against apps on builtwith.angularjs.org)

SomeKittens commented 9 years ago

Looks like we need a null check here: https://github.com/angular/angular-hint/blob/master/src/modules/scopes.js#L306

Can you find out exactly what watch is triggering the error?

gary-b commented 8 years ago

Hi SomeKittens

It was as simple as you presumed. The following code made its way into the referenced app, which ultimately was passing null to $scope.$watch.

      $scope.ngDatosPaises = null;
      $scope.guardar = function() {
        $scope.ngDatosPaises = datosPaises;
        $scope.$apply();
      };
      $scope.$watch($scope.ngDatosPaises, function() {
            // alert('hey, myVar has changed!');
            // $scope.$apply();
      });