sourcfile error

I am new to Angular 2 and Syncfusion. Not sure what this error is but whenever I add the following code
constructor(@Inject('sourceFiles') private sourceFiles: any) {
sourceFiles.files = ['sidebar-menu.css'];
}

I get the following error -
ERROR Error: StaticInjectorError(AppModule)[sourceFiles]:
StaticInjectorError(Platform: core)[sourceFiles]:
NullInjectorError: No provider for sourceFiles!
at NullInjector.push.../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:1062)
at resolveToken (core.js:1300)
at tryResolveToken (core.js:1244)
at StaticInjector.push.../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1141)
at resolveToken (core.js:1300)
at tryResolveToken (core.js:1244)
at StaticInjector.push.../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1141)
at resolveNgModuleDep (core.js:8376)
at NgModuleRef_.push.../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (core.js:9064)
at resolveDep (core.js:9429)

5 Replies

SK Suman Kumar G Syncfusion Team August 24, 2018 01:10 PM UTC

Hi Ameet,   
 
Thanks for contacting Syncfusion Support. 
 
We would like to let you know that the code been shared which has been causing the issue at your end is being used internally for our online sample browser in order to fetch and display the external CSS file (sidebar-menu.css showcasing styles used for Sidebar component) in the source code tab. Since there won’t be any similar requirement in the application level, we suggest you to remove the code to resolve this issue from your end. 
 
For your convenience, we have also created a simple sample removing the mentioned code and attached in the below link. Please check it. 
 
 
To know more about the available properties and feature in our EJ2 Sidebar component, please our online documentation in the below link. 
 
 
Please let us know if you need any further assistance. 
 
Regards, 
Sumankumar G 



AM Ameet August 24, 2018 01:57 PM UTC

Thanks for your response. I had removed it and it did work.


BM Balaji M Syncfusion Team August 27, 2018 04:58 AM UTC

Hi Ameet,  
  
Most welcome. We are happy to hear that reported query is solved.  
  
  
Regards, 
M. Balaji 



Zajkás Ágoston October 5, 2019 05:47 PM UTC

Dear Sir,

I have a very similar error with my angular project.
"constructor (@Inject('sourceFiles'private sourceFiles: any) {
    sourceFiles.files = ['card.component.css'];
  }".
I tried to change it to "dashboard.component.css" (this is my component) but nothing happens.


Devtool says:
"core.js:6014 ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppModule)[sourceFiles]: 
  StaticInjectorError(Platform: core)[sourceFiles]: 
    NullInjectorError: No provider for sourceFiles!
NullInjectorError: StaticInjectorError(AppModule)[sourceFiles]: 
  StaticInjectorError(Platform: core)[sourceFiles]: 
    NullInjectorError: No provider for sourceFiles!
    at NullInjector.get (core.js:855)
    at resolveToken (core.js:17513)
    at tryResolveToken (core.js:17439)
    at StaticInjector.get (core.js:17265)
    at resolveToken (core.js:17513)
    at tryResolveToken (core.js:17439)
    at StaticInjector.get (core.js:17265)
    at resolveNgModuleDep (core.js:30392)
    at NgModuleRef_.get (core.js:31577)
    at resolveDep (core.js:32142)
    at resolvePromise (zone-evergreen.js:797)
    at resolvePromise (zone-evergreen.js:754)
    at zone-evergreen.js:858
    at ZoneDelegate.invokeTask (zone-evergreen.js:391)
    at Object.onInvokeTask (core.js:39679)
    at ZoneDelegate.invokeTask (zone-evergreen.js:390)
    at Zone.runTask (zone-evergreen.js:168)
    at drainMicroTaskQueue (zone-evergreen.js:559)
    at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:469)
    at invokeTask (zone-evergreen.js:1603)"

So I think I don't have any sourceFiles. 
I'm looking forward to your answer and sorry for my English. :)
Ty,
BW,
Agoston


BS Balasubramanian Sattanathan Syncfusion Team October 7, 2019 12:57 PM UTC

Hai Zajkás Ágoston, 
 
Syncfusion Greetings. 
 
Kindly import the style files using below code snippet. And for the same we have prepared the sample which can be viewed from the below link. 
 
@Component({ 
    selector: 'app-root', 
    templateUrl: 'app.component.html', 
    styleUrls: ['app.component.css'], 
    encapsulation: ViewEncapsulation.None 
}) 
 
 
Regards, 
Balasubramanian S 


Loader.
Up arrow icon