<p dir="auto"><strong>I'm submitting a ...</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[x] bug report =&gt; search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request =&gt; Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question"><pre class="notranslate"><code class="notranslate">[x] bug report =&gt; search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request =&gt; Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
</code></pre></div>
<p dir="auto"><strong>Current behavior</strong></p>
<p dir="auto">When trying to use a service, if I try to provide and consume it using the 'inject' method I get the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    × should inject service
      - TypeError: Cannot read property 'injector' of null
    √ should have myNumber equal to 10
    √ should have myConstructorNumber equal to 20
    √ should have myConstructorNumber equal to 15 after ctor
    √ should persist myConstructorNumber"><pre class="notranslate"><code class="notranslate">    × should inject service
      - TypeError: Cannot read property 'injector' of null
    √ should have myNumber equal to 10
    √ should have myConstructorNumber equal to 20
    √ should have myConstructorNumber equal to 15 after ctor
    √ should persist myConstructorNumber
</code></pre></div>
<p dir="auto">(I gave up on Karma, because this issue occurs in all situations, so I thought I can single out the issue easier this way).</p>
<p dir="auto"><strong>Expected behavior</strong></p>
<p dir="auto">As you can see above, all the tests execute correctly except for one which uses the 'inject' method to provide the service instance. (rest of them are just some static variables, I only want to set up the infrastructure at this point, no actual code to test, so getting this error at this point doesn't actually seem normal).</p>
<p dir="auto"><strong>Reproduction of the problem</strong></p>
<details>
The service:
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { Injectable } from '@angular/core';

@Injectable()
export class TestService {
    static myNumber: number = 10;
    static myConstructorNumber: number = 20;

    constructor() {
        TestService.myConstructorNumber = 15;
    }
}"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-smi">Injectable</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'@angular/core'</span><span class="pl-kos">;</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">TestService</span> <span class="pl-kos">{</span>
    <span class="pl-k">static</span> <span class="pl-c1">myNumber</span>: <span class="pl-smi">number</span> <span class="pl-c1">=</span> <span class="pl-c1">10</span><span class="pl-kos">;</span>
    <span class="pl-k">static</span> <span class="pl-c1">myConstructorNumber</span>: <span class="pl-smi">number</span> <span class="pl-c1">=</span> <span class="pl-c1">20</span><span class="pl-kos">;</span>

    <span class="pl-en">constructor</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-smi">TestService</span><span class="pl-kos">.</span><span class="pl-c1">myConstructorNumber</span> <span class="pl-c1">=</span> <span class="pl-c1">15</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">The service spec:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import 'core-js';
import 'zone.js';
import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import 'zone.js/dist/sync-test';
import 'zone.js/dist/proxy';
import 'zone.js/dist/jasmine-patch';
import 'rxjs';
import 'reflect-metadata';

import {
    fakeAsync,
    inject,
    TestBed,
} from '@angular/core/testing';

import {
    TestService,
} from './test.service';

describe('Test Service', () =&gt; {
    beforeEach(() =&gt; {
        TestBed.configureTestingModule({
            providers: [
                { provide: TestService, useClass: TestService },
            ],
        });
    });

    it('should inject service',
        fakeAsync(inject([TestService], (svc: TestService) =&gt; {
            expect(TestService.myNumber).toBe(10);
        }))
    );

    it('should have myNumber equal to 10', () =&gt; {
        expect(TestService.myNumber).toBe(10);
    });

    it('should have myConstructorNumber equal to 20', () =&gt; {
        expect(TestService.myConstructorNumber).toBe(20);
    });

    it('should have myConstructorNumber equal to 15 after ctor', () =&gt; {
        new TestService();
        expect(TestService.myConstructorNumber).toBe(15);
    });

    it('should persist myConstructorNumber', () =&gt; {
        expect(TestService.myConstructorNumber).toBe(15);
    });
});"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s">'core-js'</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s">'zone.js'</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s">'zone.js/dist/long-stack-trace-zone'</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s">'zone.js/dist/async-test'</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s">'zone.js/dist/fake-async-test'</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s">'zone.js/dist/sync-test'</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s">'zone.js/dist/proxy'</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s">'zone.js/dist/jasmine-patch'</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s">'rxjs'</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-s">'reflect-metadata'</span><span class="pl-kos">;</span>

<span class="pl-k">import</span> <span class="pl-kos">{</span>
    <span class="pl-s1">fakeAsync</span><span class="pl-kos">,</span>
    <span class="pl-s1">inject</span><span class="pl-kos">,</span>
    <span class="pl-smi">TestBed</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'@angular/core/testing'</span><span class="pl-kos">;</span>

<span class="pl-k">import</span> <span class="pl-kos">{</span>
    <span class="pl-smi">TestService</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'./test.service'</span><span class="pl-kos">;</span>

<span class="pl-en">describe</span><span class="pl-kos">(</span><span class="pl-s">'Test Service'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-en">beforeEach</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-smi">TestBed</span><span class="pl-kos">.</span><span class="pl-en">configureTestingModule</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-kos">{</span> <span class="pl-c1">provide</span>: <span class="pl-smi">TestService</span><span class="pl-kos">,</span> <span class="pl-c1">useClass</span>: <span class="pl-smi">TestService</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
            <span class="pl-kos">]</span><span class="pl-kos">,</span>
        <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-en">it</span><span class="pl-kos">(</span><span class="pl-s">'should inject service'</span><span class="pl-kos">,</span>
        <span class="pl-en">fakeAsync</span><span class="pl-kos">(</span><span class="pl-en">inject</span><span class="pl-kos">(</span><span class="pl-kos">[</span><span class="pl-smi">TestService</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-s1">svc</span>: <span class="pl-smi">TestService</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
            <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-smi">TestService</span><span class="pl-kos">.</span><span class="pl-c1">myNumber</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toBe</span><span class="pl-kos">(</span><span class="pl-c1">10</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
    <span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-en">it</span><span class="pl-kos">(</span><span class="pl-s">'should have myNumber equal to 10'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-smi">TestService</span><span class="pl-kos">.</span><span class="pl-c1">myNumber</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toBe</span><span class="pl-kos">(</span><span class="pl-c1">10</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-en">it</span><span class="pl-kos">(</span><span class="pl-s">'should have myConstructorNumber equal to 20'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-smi">TestService</span><span class="pl-kos">.</span><span class="pl-c1">myConstructorNumber</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toBe</span><span class="pl-kos">(</span><span class="pl-c1">20</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-en">it</span><span class="pl-kos">(</span><span class="pl-s">'should have myConstructorNumber equal to 15 after ctor'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-k">new</span> <span class="pl-smi">TestService</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-smi">TestService</span><span class="pl-kos">.</span><span class="pl-c1">myConstructorNumber</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toBe</span><span class="pl-kos">(</span><span class="pl-c1">15</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-en">it</span><span class="pl-kos">(</span><span class="pl-s">'should persist myConstructorNumber'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-smi">TestService</span><span class="pl-kos">.</span><span class="pl-c1">myConstructorNumber</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toBe</span><span class="pl-kos">(</span><span class="pl-c1">15</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Dependency versions:</p>
<div class="highlight highlight-source-json notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&quot;dependencies&quot;: {
    &quot;@angular/common&quot;: &quot;2.0.0-rc.6&quot;,
    &quot;@angular/compiler&quot;: &quot;2.0.0-rc.6&quot;,
    &quot;@angular/core&quot;: &quot;2.0.0-rc.6&quot;,
    &quot;@angular/forms&quot;: &quot;2.0.0-rc.6&quot;,
    &quot;@angular/http&quot;: &quot;2.0.0-rc.6&quot;,
    &quot;@angular/platform-browser&quot;: &quot;2.0.0-rc.6&quot;,
    &quot;@angular/platform-browser-dynamic&quot;: &quot;2.0.0-rc.6&quot;,
    &quot;@angular/router&quot;: &quot;3.0.0-rc.2&quot;,
    &quot;@angular/upgrade&quot;: &quot;2.0.0-rc.6&quot;,
    &quot;angular2-in-memory-web-api&quot;: &quot;0.0.18&quot;,
    &quot;reflect-metadata&quot;: &quot;0.1.8&quot;,
    &quot;rxjs&quot;: &quot;5.0.0-beta.11&quot;,
    &quot;systemjs&quot;: &quot;0.19.38&quot;,
    &quot;zone.js&quot;: &quot;0.6.17&quot;
  },
  &quot;devDependencies&quot;: {
    &quot;@types/core-js&quot;: &quot;^0.9.32&quot;,
    &quot;@types/jasmine&quot;: &quot;^2.2.33&quot;,
    &quot;@types/node&quot;: &quot;^4.0.22-alpha&quot;,
    &quot;@types/requirejs&quot;: &quot;^2.1.26&quot;,
    &quot;gulp&quot;: &quot;^3.9.1&quot;,
    &quot;gulp-babel&quot;: &quot;^6.1.2&quot;,
    &quot;gulp-clean&quot;: &quot;^0.3.2&quot;,
    &quot;gulp-sourcemaps&quot;: &quot;^1.6.0&quot;,
    &quot;gulp-tslint&quot;: &quot;^6.1.1&quot;,
    &quot;gulp-typescript&quot;: &quot;^2.13.6&quot;,
    &quot;gulpclass&quot;: &quot;^0.1.1&quot;,
    &quot;jasmine&quot;: &quot;^2.5.0&quot;,
    &quot;jasmine-spec-reporter&quot;: &quot;^2.7.0&quot;,
    &quot;phantomjs&quot;: &quot;^2.1.7&quot;,
    &quot;phantomjs-polyfill&quot;: &quot;0.0.2&quot;,
    &quot;tslint&quot;: &quot;^3.15.1&quot;,
    &quot;typescript&quot;: &quot;^2.0.2&quot;
  },"><pre class="notranslate"><span class="pl-ent">"dependencies"</span>: {
    <span class="pl-ent">"@angular/common"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.0.0-rc.6<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"@angular/compiler"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.0.0-rc.6<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"@angular/core"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.0.0-rc.6<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"@angular/forms"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.0.0-rc.6<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"@angular/http"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.0.0-rc.6<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"@angular/platform-browser"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.0.0-rc.6<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"@angular/platform-browser-dynamic"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.0.0-rc.6<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"@angular/router"</span>: <span class="pl-s"><span class="pl-pds">"</span>3.0.0-rc.2<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"@angular/upgrade"</span>: <span class="pl-s"><span class="pl-pds">"</span>2.0.0-rc.6<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"angular2-in-memory-web-api"</span>: <span class="pl-s"><span class="pl-pds">"</span>0.0.18<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"reflect-metadata"</span>: <span class="pl-s"><span class="pl-pds">"</span>0.1.8<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"rxjs"</span>: <span class="pl-s"><span class="pl-pds">"</span>5.0.0-beta.11<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"systemjs"</span>: <span class="pl-s"><span class="pl-pds">"</span>0.19.38<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"zone.js"</span>: <span class="pl-s"><span class="pl-pds">"</span>0.6.17<span class="pl-pds">"</span></span>
  },
  <span class="pl-ent">"devDependencies"</span>: {
    <span class="pl-ent">"@types/core-js"</span>: <span class="pl-s"><span class="pl-pds">"</span>^0.9.32<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"@types/jasmine"</span>: <span class="pl-s"><span class="pl-pds">"</span>^2.2.33<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"@types/node"</span>: <span class="pl-s"><span class="pl-pds">"</span>^4.0.22-alpha<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"@types/requirejs"</span>: <span class="pl-s"><span class="pl-pds">"</span>^2.1.26<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"gulp"</span>: <span class="pl-s"><span class="pl-pds">"</span>^3.9.1<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"gulp-babel"</span>: <span class="pl-s"><span class="pl-pds">"</span>^6.1.2<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"gulp-clean"</span>: <span class="pl-s"><span class="pl-pds">"</span>^0.3.2<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"gulp-sourcemaps"</span>: <span class="pl-s"><span class="pl-pds">"</span>^1.6.0<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"gulp-tslint"</span>: <span class="pl-s"><span class="pl-pds">"</span>^6.1.1<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"gulp-typescript"</span>: <span class="pl-s"><span class="pl-pds">"</span>^2.13.6<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"gulpclass"</span>: <span class="pl-s"><span class="pl-pds">"</span>^0.1.1<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"jasmine"</span>: <span class="pl-s"><span class="pl-pds">"</span>^2.5.0<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"jasmine-spec-reporter"</span>: <span class="pl-s"><span class="pl-pds">"</span>^2.7.0<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"phantomjs"</span>: <span class="pl-s"><span class="pl-pds">"</span>^2.1.7<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"phantomjs-polyfill"</span>: <span class="pl-s"><span class="pl-pds">"</span>0.0.2<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"tslint"</span>: <span class="pl-s"><span class="pl-pds">"</span>^3.15.1<span class="pl-pds">"</span></span>,
    <span class="pl-ent">"typescript"</span>: <span class="pl-s"><span class="pl-pds">"</span>^2.0.2<span class="pl-pds">"</span></span>
  },</pre></div>
</details>
<p dir="auto"><strong>Reason:</strong><br>
I'm trying to set this up for the following reason: the project I'm building right now will have all core logic (Services/Pipes etc.) in a different repository that will be referenced as a git submodule in all client repositories. So I will only need to test Injectable classes.</p>
<p dir="auto"><strong>Please tell us about your environment:</strong></p>
<ul dir="auto">
<li><strong>Angular version:</strong> 2.0.0-rc.6</li>
<li><strong>Browser:</strong> [all]</li>
<li><strong>Language:</strong> [TypeScript 2.0]</li>
</ul>
<p dir="auto">When I tried to add active class to active route to my navbar, I found the following bug in router.isActive function:<br>
isActive function returns true in all dasboard elements, so all links looks active with exact true parameter,</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;li *ngFor=&quot;let item of dashboards&quot; 
            [class.active]=&quot;router.isActive(router.createUrlTree(['dashboard', { dashboard: item }]), true)&quot;&gt;
    &lt;a [routerLink]=&quot;['./dashboard',  { dashboard: item }]&quot;&gt;
       {{ item }}
    &lt;/a&gt;
&lt;/li&gt;"><pre class="notranslate"><code class="notranslate">&lt;li *ngFor="let item of dashboards" 
            [class.active]="router.isActive(router.createUrlTree(['dashboard', { dashboard: item }]), true)"&gt;
    &lt;a [routerLink]="['./dashboard',  { dashboard: item }]"&gt;
       {{ item }}
    &lt;/a&gt;
&lt;/li&gt;
</code></pre></div>
<p dir="auto">The router is Angular2 router and the dashboards is <code class="notranslate">public dashboards: string[];</code></p>