Angular Error : StaticInjectorError (Platform: core)[e -> t]:

后端 未结 2 736
有刺的猬
有刺的猬 2021-01-20 17:18

As I am build the APK with --prod I am getting the error below

    ERROR Error: StaticInjectorError[e -> t]: 
  StaticInjectorError(Platform:         


        
2条回答
  •  太阳男子
    2021-01-20 18:12

    This happens because you did not add the services used to build the module

    example:

    1. component

    @Component({
      selector: 'app-sample',
      templateUrl: './sample.component.html',
      styleUrls: ['./sample.component.scss']
    })
    export class SampleComponent implements OnInit {
    
    constructor(private localServiceName: YourService) {
    }
    
      ngOnInit() {
      }
    
    }
    

    2. module

    @NgModule({
        declarations: [SampleComponent]
    })
    

    change to

    @NgModule({
        declarations: [SampleComponent]
        providers: [ YourService ]
    })
    

提交回复
热议问题