Angular 2: No provider for (injected) service

后端 未结 2 822
太阳男子
太阳男子 2021-02-01 17:48

I have two services in my app - MainService and RightClickService. Only MainService is accessible globally in the application, and RightClickService is injected to MainService.

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-01 18:40

    I just pulled this into a Plunker, and unless I mistyped something ... what you have seems to work. So maybe there is something else wrong?

    Can you check out the plunker here: https://plnkr.co/edit/ea9dFs?p=info

    (The tool won't let me post without the code ... but you already have the code above ... so I'm just pasting a piece of it.)

    import { Injectable } from '@angular/core'
    
     @Injectable()
     export class RightClickService {
    
      constructor() {
        console.log("RightClickService is init");
      }
    }
    

提交回复
热议问题