'No provider' error (even though I've added a provider)

后端 未结 3 1218
走了就别回头了
走了就别回头了 2021-01-20 18:18

I\'m trying to call a service from a particular class, but for some reason it can\'t be called, even though I am able to use it in other classes. I\'m using @Input

3条回答
  •  天命终不由人
    2021-01-20 18:38

    In my case, I imported the service as

    import {MyService} from '../services/my.service'
    

    in one place, and

    import {MyService} from '../services/index'
    

    in the other place, while index.ts contains all export statements for services in the same folder.

    After I unified to the 2nd form of importing, the problem had gone.

提交回复
热议问题