Providing a component doesn't do anything meaningful. You'll get an instance of the component class injected where the @Component()` decorator is completely ignored. Rather share a service and use streams to communicate between the component and all other components and services that want to communicate with it.
On Saturday, June 25, 2016 at 8:48:09 PM UTC+2, Gonzalo Chumillas wrote: > > I would like to make a component available for all other components and > inject it as a service. The following code won't work, since Angular 2 > actually creates two instances of ModalPreloader: > > // file: app_component.dart > @Component( > selector: 'app-component', > templateUrl: 'app_component.html', > styleUrls: const ['app_component.css'], > // a "Modal Preloader" is at the same time a "directive" and a > "service" > directives: const [ModalPreloader], > providers: const [ModalPreloader]) > AppComponent {} > > > // file: app_component.html > // html code... > // Modal Preloader component > <modal-preloader></modal-preloader> > > > Is it possible to inject an existing component as if it were a service? > This way, I could access that component from any sub-component. > Thanks. > -- You received this message because you are subscribed to the Google Groups "angular-dart" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular-dart+unsubscr...@googlegroups.com. Visit this group at https://groups.google.com/group/angular-dart. To view this discussion on the web visit https://groups.google.com/d/msgid/angular-dart/30a55d9d-b4fb-4671-8257-67588d5c02bd%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.