Skip to main content
Found root cause.
Source Link
Levi Fuller
  • 16.1k
  • 4
  • 41
  • 46

Apparently you cannot inject a service into another service while using versionI just learned that the import statement paths are case-sensitive.

I had 2import {UserService} from '.0.0-rc/.1./services/user.service'; ofwhile the directory was @angular../router../SERVICES/user.service yet.

I altered changed my application to use @angular/router-deprecated instead and now it injects just fine.Where's the facepalm emoji?

import { Component, OnInit } from '@angular/core';
import { 
  RouteConfig, 
  // Routes
  ROUTER_DIRECTIVES } from '@angular/router-deprecated';
import { LoginPage, AddCandidatePage } from './export';

@Component({
  moduleId: 'app/',
  selector: 'my-app',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.css'],
  providers: [UserService],
  directives: [ROUTER_DIRECTIVES]
})

@RouteConfig([
  {
    name: 'AddCandidate', // Can remove with '@angular/router'
    path: '/', component: AddCandidatePage},
   {name: 'Login', path: 'Login', component: LoginPage}
])
export class AppComponent { }

Apparently you cannot inject a service into another service while using version 2.0.0-rc.1 of @angular/router yet.

I altered changed my application to use @angular/router-deprecated instead and now it injects just fine.

import { Component, OnInit } from '@angular/core';
import { 
  RouteConfig, 
  // Routes
  ROUTER_DIRECTIVES } from '@angular/router-deprecated';
import { LoginPage, AddCandidatePage } from './export';

@Component({
  moduleId: 'app/',
  selector: 'my-app',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.css'],
  providers: [UserService],
  directives: [ROUTER_DIRECTIVES]
})

@RouteConfig([
  {
    name: 'AddCandidate', // Can remove with '@angular/router'
    path: '/', component: AddCandidatePage},
   {name: 'Login', path: 'Login', component: LoginPage}
])
export class AppComponent { }

I just learned that the import statement paths are case-sensitive.

I had import {UserService} from '../../services/user.service'; while the directory was ../../SERVICES/user.service.

Where's the facepalm emoji?

Source Link
Levi Fuller
  • 16.1k
  • 4
  • 41
  • 46

Apparently you cannot inject a service into another service while using version 2.0.0-rc.1 of @angular/router yet.

I altered changed my application to use @angular/router-deprecated instead and now it injects just fine.

import { Component, OnInit } from '@angular/core';
import { 
  RouteConfig, 
  // Routes
  ROUTER_DIRECTIVES } from '@angular/router-deprecated';
import { LoginPage, AddCandidatePage } from './export';

@Component({
  moduleId: 'app/',
  selector: 'my-app',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.css'],
  providers: [UserService],
  directives: [ROUTER_DIRECTIVES]
})

@RouteConfig([
  {
    name: 'AddCandidate', // Can remove with '@angular/router'
    path: '/', component: AddCandidatePage},
   {name: 'Login', path: 'Login', component: LoginPage}
])
export class AppComponent { }