Snixells
Snixells

Reputation: 121

I cant find my service Path in Angular 2

i am searching for this path for hours now and hope you could help me. I created a service and want to access it from my components.

My files are organized like that:

My files are organized like that:

I want to import "shared.service.ts" to "main-quiz.component.ts.

I already tried

import { SharedService } from './shared,service';
import { SharedService } from '././shared,service';
import { SharedService } from 'src/app/shared.service';

I really dont know why that is not working... Please help me, thanks!

Upvotes: 0

Views: 292

Answers (3)

nagrom97
nagrom97

Reputation: 514

import { SharedService} from '../shared.service;

Which means "I want to find the file from the directory above"

Likewise , if it was two directories above , you'd do something like: '../../filename'

Upvotes: 1

alehn96
alehn96

Reputation: 1393

import { SharedService } from '../shared.service'; 

where .. is parent directory

Upvotes: 0

CharanRoot
CharanRoot

Reputation: 6325

try this.

import { SharedService } from '../shared,service';

Upvotes: 0

Related Questions