Last I heard, this was working as intended <https://github.com/angular/angular/issues/1639>. Still feels strange to me, though.
On Wednesday, June 17, 2015 at 3:02:19 AM UTC-5, Georgios Diamantopoulos wrote: > > Still seeing this in alpha 26. Any news since this last post? > > > > On Sunday, April 26, 2015 at 9:52:24 PM UTC+3, David Lesage wrote: >> >> I agree -- and I'm not convinced that it's not a bug. I feel like di.js >> should be able to resolve those child dependencies without needing to have >> them injected. I've seen it work that way, at any rate. You can just run >> injector.get(TopLevelComponent) and all child level dependencies can be >> resolved (either through typescript or explicit @Inject calls). >> >> Side note (somewhat related), take a look at this: >> http://plnkr.co/edit/UyNe7a4wD3OWXGTyWlAI?p=preview >> >> Note that AnotherService has its id incremented multiple times, which I >> believe indicates that the dependency injection is creating a new instance >> each time. >> Now remove AnotherService from NameComponent's injectables (line 36). I >> am seeing that works as I had expected -- a single instance of a service >> injected across all components. >> >> And a second side note (not really related), I just realized I don't know >> how to get information from the parent DisplayComponent into the child >> NameComponent. Any thoughts? I know Angular1.x would just slap the data on >> the child directive's $scope. I played around with the (load) event for a >> bit, but wasn't having any real luck (and I'm not sure if that's the best >> way of going about that, anyways). >> >> >> >> On Sunday, April 26, 2015 at 4:29:28 AM UTC-7, Milan Pevec wrote: >>> >>> Thank you, it's a lit a bit strange to include everything in the >>> @Component injectables, but its working like this. >>> >>> Milan >>> >>> On Saturday, April 25, 2015 at 7:57:33 AM UTC+2, David Lesage wrote: >>>> >>>> Take a look at this plunker: >>>> http://plnkr.co/edit/UyNe7a4wD3OWXGTyWlAI?p=preview >>>> >>>> I took one of the templates from the angular website and extended it -- >>>> One thing to note (and I'm not sure if this is intentional or not, doesn't >>>> seem to be necessary with di.js), I had to include @Component injectables >>>> as [Service, AnotherService], instead of just the parent dependency of >>>> AnotherService. Try it for yourself -- if I remove Service from that >>>> array, >>>> the whole thing breaks for me. >>>> >>>> Whether that's intentional behavior or not, I'm not sure, but that's >>>> what I saw earlier with the dependency injection in the quickstart code as >>>> well. >>>> >>>> On Fri, Apr 24, 2015 at 3:15 AM, Milan Pevec <[email protected]> >>>> wrote: >>>> >>>>> So this should work or did I miss something ? >>>>> >>>>> http://plnkr.co/edit/ehV8PojejoTk1h28VsPb?p=preview >>>>> >>>>> Milan >>>>> >>>>> >>>>> On Friday, April 24, 2015 at 10:34:02 AM UTC+2, Milan Pevec wrote: >>>>>> >>>>>> Thank you for the answer and yes I see the same error.. >>>>>> >>>>>> Milan >>>>>> >>>>>> On Thursday, April 23, 2015 at 6:50:58 PM UTC+2, David Lesage wrote: >>>>>>> >>>>>>> Yes and no -- My next step was to update the Angular2 code by >>>>>>> grabbing it off of github, followed by grabbing all of the dependencies >>>>>>> myself (SystemJS, Traceur, etc) and starting from scratch. I eventually >>>>>>> got >>>>>>> it into a state where all of the injection *mostly* worked, but I >>>>>>> was getting an issue where multiple injections of the same type in >>>>>>> different locations were not the same instance, and I was getting some >>>>>>> unexpected behavior while trying to create a local cache/store/whatever >>>>>>> you >>>>>>> want to call it. That was either a bug (unlikely), a user-error (seems >>>>>>> more >>>>>>> likely), or just me misunderstanding the dependency injection >>>>>>> expectations >>>>>>> in Angular2. >>>>>>> >>>>>>> At that point I broke it down further, and I grabbed the di.js >>>>>>> <https://github.com/angular/di.js/> code directly from Angular's >>>>>>> github and ran with that separately to make sure my expectations >>>>>>> weren't >>>>>>> incorrect -- but that worked exactly as I expected. Phenomenally, in >>>>>>> fact >>>>>>> -- I loved it. They have better examples >>>>>>> <https://github.com/angular/di.js/tree/master/example/kitchen-di>than >>>>>>> anything I could give, though. >>>>>>> >>>>>>> I suppose the TL;DR is -- No, I never got it fully working. Are you >>>>>>> seeing the same error I was? >>>>>>> >>>>>>> >>>>>>> On Thursday, April 23, 2015 at 7:42:25 AM UTC-7, Milan Pevec wrote: >>>>>>>> >>>>>>>> Hi David, >>>>>>>> >>>>>>>> did you maybe find the solution ? >>>>>>>> >>>>>>>> Regards, >>>>>>>> Milan >>>>>>>> >>>>>>>> On Friday, April 3, 2015 at 7:01:37 PM UTC+2, David Lesage wrote: >>>>>>>>> >>>>>>>>> Absolutely, that looks perfect. Is that syntax functional, or just >>>>>>>>> proposed? I'm wondering if I need a newer version of Angular2 than >>>>>>>>> what is >>>>>>>>> included with the quickstart to get that to work. >>>>>>>>> >>>>>>>>> I'm currently not having any luck with the following: >>>>>>>>> >>>>>>>>> import {DispatcherService} from 'services/DispatcherService'; >>>>>>>>> import {Inject} from 'angular2/di'; >>>>>>>>> >>>>>>>>> @Inject(DispatcherService) // had to remove the semicolon, was >>>>>>>>> getting an 'Unsupported annotated expression' error >>>>>>>>> export class TodoStore { >>>>>>>>> constructor(dispatcher: DispatcherService) {} >>>>>>>>> } >>>>>>>>> >>>>>>>>> I am still receiving the *No provider for DispatcherService! >>>>>>>>> (TodosComponent -> TodoStore -> DispatcherService) *error. >>>>>>>>> >>>>>>>>> >>>>>>>>> On Friday, April 3, 2015 at 2:28:19 AM UTC-7, Sander Elias wrote: >>>>>>>>>> >>>>>>>>>> Hi David, >>>>>>>>>> >>>>>>>>>> You mean you want somethig like this: >>>>>>>>>> >>>>>>>>>> export function threeStrikes (req:Request|string) { >>>>>>>>>> return this.http(req).retry(3); >>>>>>>>>> } >>>>>>>>>> >>>>>>>>>> @Inject(threeStrikes); >>>>>>>>>> export class MyComponent { >>>>>>>>>> constructor(threeStrikes) { >>>>>>>>>> >>>>>>>>>> threeStrikes('[http://foo.bar](http://foo.bar/)').subscribe(onNext, >>>>>>>>>> onError); >>>>>>>>>> } >>>>>>>>>> } >>>>>>>>>> >>>>>>>>>> This is a Sample Jeff provided in another setting, but I think it >>>>>>>>>> is what you are asking, right? >>>>>>>>>> >>>>>>>>>> Regards >>>>>>>>>> Sander >>>>>>>>>> >>>>>>>>>> >>>>>>>>> -- >>>>> You received this message because you are subscribed to a topic in the >>>>> Google Groups "AngularJS" group. >>>>> To unsubscribe from this topic, visit >>>>> https://groups.google.com/d/topic/angular/PPl6jxL5zps/unsubscribe. >>>>> To unsubscribe from this group and all its topics, send an email to >>>>> [email protected]. >>>>> To post to this group, send email to [email protected]. >>>>> Visit this group at http://groups.google.com/group/angular. >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
