pbastowski / angular2-now

Angular 2 @Component syntax for Angular 1 apps
MIT License
145 stars 15 forks source link

Error when using resolve in @State #14

Closed vacarsu closed 9 years ago

vacarsu commented 9 years ago
Uncaught Error: [$injector:unpr] Unknown provider: $rootElementProvider <- $rootElement <- $$animateQueue <- $animate <- $compile <- $$animateQueue
http://errors.angularjs.org/1.4.1/$injector/unpr?p0=%24rootElementProvider%…eQueue%20%3C-%20%24animate%20%3C-%20%24compile%20%3C-%20%24%24animateQueue

I think it must be caused by one of the recent updates, I have tried both of the following.

@State({
  name: 'root.subscription',
  url: '/subscription',
  resolve: {
    currentUser: function($meteor) { return $meteor.waitForUser(); }
  }
})

and I know this one works in several of my other apps that I have not updated.

@State({
  name: 'root.subscription',
  url: '/subscription',
  resolve: {
    'currentUser': ['$meteor', function($meteor){
      return $meteor.waitForUser();
    }]
  }
})
pbastowski commented 9 years ago

I also saw this error and am trying to track it down. Not a 100% sure, but I think it is something to do with the Meteor package version clashes / incompatibility. But, still looking

In the meantime, I have a jsbin, http://jsbin.com/tipeqa/12/edit?html,js,output, which shows that I can resolve a value and use ngAnimate with Angular 1.4.2 and with the latest version of angular2-now code.

Why do I mention ngAnimate? Because I only get this error when I add ngAnimate as a dependency to my app.

To be continued... :)

vacarsu commented 9 years ago

Ah I see, well. I can't really give up ngAnimate as I'm using angular-material.

pbastowski commented 9 years ago

I'm not giving up either. Still looking for a solution that works reliably with Meteor.

vacarsu commented 9 years ago

Do you suggest I downgrade to an older version in the meantime, and if so what version do you suggest I use?

pbastowski commented 9 years ago

I found the bug and fixed it in v 0.3.4. Please try

meteor update

and let me know if this fixes it for you.

vacarsu commented 9 years ago

Yes, looks like it's working great! I just need to find a local storage package. mrt:ngstorage throws an error as soon as I install it. Do you know of one already wrapped for meteor? I've tried wrapping several other packages like braintree-angular, and have never succeeded. It seems like npm packages do not like being imported from the meteor server to the client. At least I assume this is what is happening.

pbastowski commented 9 years ago

Actually, localStorage is very easy to use and does not require any kind of package, see below:

var ls = window.localStorage
ls.setItem('myvar', 123)
ls.getItem('myvar')  // >>> "123"

Type the above in your dev console. This works from IE8 and up, which is very nice :)

vacarsu commented 9 years ago

Oh nice, I will try that. Thanks.