angular: Can't extend IterableDiffers

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Not sure If I am missing something or it’s a bug. But if you do as follows I get “Cannot extend IterableDiffers without a parent injector” exception.

@NgModule({
  imports: [BrowserModule],
  providers: [IterableDiffers.extend([new FooIterableDifferFactory()])]
  bootstrap: [Foo]
});
export class AppModule { }

platformBrowserDynamic().bootstrapModule(AppModule);

Expected/desired behavior

It’s possible to extend default iterable differs in the application module.

Please tell us about your environment:

  • Angular version: 2.0.0-rc.6
  • Browser: [all]
  • Language: [all]

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 2
  • Comments: 20 (9 by maintainers)

Commits related to this issue

Most upvoted comments

just discussed with @vsavkin, we should have a solution by the next release (probably 2.0.1)

@htafolla I’m going to take a look asap.

@vicb is this scheduled to be resolved in the next maintenance release? There is a growing community looking to use Angular 2.0.0 with Meteor. Based on the latest posts on the corresponding thread, this item is the only one remaining to make the jump.

@vicb Here is a plunker where a custom differ factory is supposed to be used but it throws “Cannot extend IterableDiffers without a parent injector” when I am trying to use IterableDiffers.extend. https://plnkr.co/edit/YVRZ6gNq7LMr2DAJvRAf?p=preview

As before, we extended standard differs by providing new instance of IterableDiffers with all differ factories added plus our custom differ factory. In order to get all available differ factories to pass them into IterableDiffers constructor, we relied on some internal code, i.e. https://github.com/Urigo/angular2-meteor/blob/master/modules/providers.ts#L6

It’s be awesome if you made access to the standard differ factory public (i.e. this one https://github.com/angular/angular/blob/master/modules/%40angular/core/src/change_detection/change_detection.ts#L35), so we could use it to extend IterableDiffers in the same way as before, or made IterableDiffers.extend is not dependable on the default differ.

@chrisse27 hm, this is how it was before. I thought for some reason they got (or gonna get) rid of providers in components. Anyways makes sense to fix it for modules as well.