<p dir="auto">We agreed today that the metadata we produce for a single project should contain only relative paths, because we do not need to reference symbols that originated in a different node package.</p>
<p dir="auto">This is a smell because we are about to change our package names, and the string 'angular2' does not appear anymore, however the metadata ought to remain unchanged (because the .d.ts files will not be affected)</p>
<p dir="auto"><a href="https://raw.githubusercontent.com/angular/angular/builds-js/src/common/forms/directives/ng_control_name.metadata.json" rel="nofollow">https://raw.githubusercontent.com/angular/angular/builds-js/src/common/forms/directives/ng_control_name.metadata.json</a></p>
<p dir="auto">Is an example of two problems:</p>
<ul dir="auto">
<li>there is a <code class="notranslate">module</code> in the top-level <code class="notranslate">__symbolic</code> definition, this duplicates information available in the file's path, and differs from <code class="notranslate">.d.ts</code> files, which do not declare their own module name. PROPOSAL: remove module from the schema (<a href="https://github.com/angular/angular/blob/master/tools/metadata/src/schema.ts#L5">https://github.com/angular/angular/blob/master/tools/metadata/src/schema.ts#L5</a> )</li>
<li>references to other angular code should be relative, not absolute names starting with 'angular2'. PROPOSAL: simply use the path.relative function in nodejs to relativize the path of a module from the containing file, whole metadata we are gathering.</li>
</ul>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/tbosch/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/tbosch">@tbosch</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/chuckjaz/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/chuckjaz">@chuckjaz</a></p>
<p dir="auto">Hello,</p>
<p dir="auto">I'm submitting a FEATURE REQUEST / QUESTION.</p>
<p dir="auto">I am aware that Angular2 default DI Context strategy is to enrich an application-wide Dependency Injection Context. But I would like some Injectables to not be globally available.</p>
<p dir="auto">Here is a concrete example of what I am trying to achieve.<br>
There is probably a doc explaining how to do so but I have not been able to find it.</p>
<p dir="auto">I would like to create a ServiceModule that would differentiate Public/Exported services from Private services.</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@Injectable() export class PrivateService{} // Not available in AppModule
@Injectable() export class PubliclyExportedService{ // Available in AppModule
  constructor(private privateService: PrivateService) { }
}

// The imported module
@NgModule({
  exports: [PubliclyExportedService],
  declarations: [PubliclyExportedService],
  providers: [
    PubliclyExportedService,
    PrivateService
  ]
})
export class ServiceModule {}

// The main module
@NgModule({
  imports: [ServiceModule]
})
export class AppModule { }"><pre class="notranslate">@<span class="pl-smi">Injectable</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-k">export</span> <span class="pl-k">class</span> <span class="pl-smi">PrivateService</span><span class="pl-kos">{</span><span class="pl-kos">}</span> <span class="pl-c">// Not available in AppModule</span>
@<span class="pl-smi">Injectable</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-k">export</span> <span class="pl-k">class</span> <span class="pl-smi">PubliclyExportedService</span><span class="pl-kos">{</span> <span class="pl-c">// Available in AppModule</span>
  <span class="pl-en">constructor</span><span class="pl-kos">(</span><span class="pl-k">private</span> <span class="pl-s1">privateService</span>: <span class="pl-smi">PrivateService</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span>

<span class="pl-c">// The imported module</span>
@<span class="pl-smi">NgModule</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
  <span class="pl-c1">exports</span>: <span class="pl-kos">[</span><span class="pl-smi">PubliclyExportedService</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
  <span class="pl-c1">declarations</span>: <span class="pl-kos">[</span><span class="pl-smi">PubliclyExportedService</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
  <span class="pl-c1">providers</span>: <span class="pl-kos">[</span>
    <span class="pl-smi">PubliclyExportedService</span><span class="pl-kos">,</span>
    <span class="pl-smi">PrivateService</span>
  <span class="pl-kos">]</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span>
<span class="pl-k">export</span> <span class="pl-k">class</span> <span class="pl-smi">ServiceModule</span> <span class="pl-kos">{</span><span class="pl-kos">}</span>

<span class="pl-c">// The main module</span>
@<span class="pl-smi">NgModule</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
  <span class="pl-c1">imports</span>: <span class="pl-kos">[</span><span class="pl-smi">ServiceModule</span><span class="pl-kos">]</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span>
<span class="pl-k">export</span> <span class="pl-k">class</span> <span class="pl-smi">AppModule</span> <span class="pl-kos">{</span> <span class="pl-kos">}</span></pre></div>
<p dir="auto">The goal is to use the dependency injection so that <code class="notranslate">PubliclyExportedService</code> can use <code class="notranslate">PrivateService</code> but any class outside of the <code class="notranslate">ServiceModule</code> would not be capable of injecting the <code class="notranslate">PrivateService</code>.</p>
<p dir="auto">Any help is greatly appreciated</p>
<p dir="auto">PS: This is a duplicate of a <a href="http://stackoverflow.com/questions/41935142/angular2-module-with-private-nested-di-context" rel="nofollow">stackoverflow question</a> where nobody seemed to have an answer to this problem.</p>