-------------------------------------------- On Sun, 1/1/17, 'Lucas Lacroix' via Angular <[email protected]> wrote:
Subject: Re: [AngularJS] why do we have to import Http in a service even if we import it in app module? To: [email protected] Date: Sunday, January 1, 2017, 1:21 PM Again... This has nothing to do with Angular or the "app module". This is how ES6 imports and Typescript work and it is how imports work in most languages. Every module/file that needs a definition must import the file that contains that definition. In this case, the definition is for the Http module. This is so the system knows exactly which module you mean to reference within your module. Module imports are not inherited because it would make certain things impossible. For example: no module that you imported could ever have a module with the same name as any other module in any library that you are using. On Sun, Jan 1, 2017 at 6:14 AM Sathish VJ <[email protected]> wrote: Would it not be enough then to do it in the app module since it will be available down the component tree? Or is it only certain things that are available in the hierarchy? If yes, which ones are they? On Sunday, 1 January 2017 16:38:56 UTC+5:30, Lucas Lacroix wrote:Hi Sathish,You're importing the definitions so that they can be referenced within your code. This is fairly typical of most languages that do imports (Java, C++, C#, etc.) and is not specific to Angular. On Sun, Jan 1, 2017 at 5:55 AM Sathish VJ <[email protected]> wrote: I did not quite understand what needs to be imported only once and what all multiple times. Why is it not enough to import Http only once in app-module? Why do I have to import it again in every service? -- You received this message because you are subscribed to the Google Groups "Angular" 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 https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout. -- Lucas LacroixComputer ScientistAdvanced Technology Division, MEDITECH781-774-2293 -- You received this message because you are subscribed to the Google Groups "Angular" 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 https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout. -- Lucas LacroixComputer ScientistAdvanced Technology Division, MEDITECH781-774-2293 -- You received this message because you are subscribed to the Google Groups "Angular" 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 https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout. a aproape un an de la retragerea trupelor tariste din tarile Romane cei doi domni isi recuperau tronurile la sfarsitul lunii septembrie 1854: Barbu stirbey in tara Romaneasca a manifestat o atitudine defavorabila miscarii unioniste sperand sa obtina o noua candidatura la tron. in Moldova insa Grigore Alexandru Ghica a inlesnit editarea unor publicatii ca Romania literara si Steaua Dunarii cu rol important in pregatirea spiritelor pentru Unire in formarea constiintei nationale. -- You received this message because you are subscribed to the Google Groups "Angular" 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 https://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
