I\'m trying to make a shared service for my app.
import { Injectable } from \'@angular/core\';
@Injectable()
export class SharedService {
testService() {
I believe you use latest version and want to use singleton service.
For that you have to register your service in @NgModule({})
as shown here,
import {Sharedservice} from 'valid path';
@NgModule({
imports:[BroswerModule],
...
providers:[SharedService]
})
Now, In child and parent component just import Sharedservice at the top of the file.
NOTE : Remove providers:[SharedService]
from each component.