Urigo / angular-meteor

Angular and Meteor - The perfect stack
https://www.angular-meteor.com/
MIT License
2.36k stars 622 forks source link

Component As Syntax Throws Tracker Error (angular 1.x) #1279

Closed elHoudini9 closed 8 years ago

elHoudini9 commented 8 years ago

Hi all,

this controller is breaking my app, which uses the 'component as' syntax (angular 1.x). It's curious, because I use the same syntax in all of the other controllers, but only breaks 2 of my controllers. I tried copy-pasting the code from working controllers and replacing the contents, but no luck....

angular.module('testApp').directive('breadcrumbs', function () {
  return {
    restrict: 'E',
    templateUrl: 'client/components/breadcrumbs/breadcrumbs.html',
    controllerAs: 'breadcrumbs',
    controller: function($scope, $reactive, $location) {
      $reactive(this).attach($scope);

      this.urlArr = $location.path().split('/').splice(1);
      console.log('ROuterrrrL', this.urlArr);
    }
  }
});

When I comment out the line stated below, the code doesn't throw the error. $reactive(this).attach($scope);

These are the 2 error message that I get if the line is uncommented:

Exception in queued task: TypeError: Cannot read property 'splice' of undefined
    at http://localhost:3000/packages/angular-meteor-data.js?36dfe4bee5b3da21eaa0d9bc0366addac4788a1a:2134:30
    at http://localhost:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:310:31
    at Object.Tracker.nonreactive (http://localhost:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:615:12)
    at Tracker.Computation.invalidate (http://localhost:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:309:15)
    at Tracker.Dependency.changed (http://localhost:3000/packages/tracker.js?7776276660c988c38fed448d8262b925dffb5bc3:443:30)
    at http://localhost:3000/packages/minimongo.js?cdf1a26cf7719fa9471a8017c3defd5aea812727:407:13
    at _.extend.runTask (http://localhost:3000/packages/meteor.js?9730f4ff059088b3f7f14c0672d155218a1802d4:685:11)
    at _.extend.flush (http://localhost:3000/packages/meteor.js?9730f4ff059088b3f7f14c0672d155218a1802d4:713:10)
    at _.extend.drain (http://localhost:3000/packages/meteor.js?9730f4ff059088b3f7f14c0672d155218a1802d4:721:12)
    at LocalCollection.insert (http://localhost:3000/packages/minimongo.js?cdf1a26cf7719fa9471a8017c3defd5aea812727:615:22)
-----------------------------------------------------------------------------------------
Exception from Tracker recompute function:
debug.js:41 TypeError: Cannot read property 'changed' of undefined
    at Scope.$$Reactive.$$changed (angular-meteor.js:2199)
    at angular-meteor.js:2099
    at Object.Tracker.nonreactive (tracker.js:589)
    at controller.<anonymous> (angular-meteor.js:2083)
    at angular-meteor.js:1563
    at Tracker.Computation._compute (tracker.js:323)
    at Tracker.Computation._recompute (tracker.js:342)
    at Object.Tracker._runFlush (tracker.js:481)
    at onGlobalMessage (setimmediate.js:102)

Any ideas? Why does it work in some places and not the others?

elHoudini9 commented 8 years ago

The component was inside of another component. I suspect that this may have caused it.

ThomsCass commented 8 years ago

see #1269

elHoudini9 commented 8 years ago

@ThomsCass Thank you good sir. Closing this one