-
Notifications
You must be signed in to change notification settings - Fork 42
StaticInjectorError[DomSanitizer] with Angular 5 // Solution: --preserve-symlinks
#4
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Give me more details to reproduce the bug. |
I checked it on an empty project with Angular5 and don't found the bug. Angular CLI: 1.6.6
Node: 9.4.0
OS: linux x64
Angular: 5.2.3 src/app/app.module.ts import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {AppComponent} from './app.component';
import {NgxSelectModule} from 'ng2-select-ex';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
NgxSelectModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
} src/app/app.component.ts import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
} src/app/app.component.html <ngx-select [items]="['sdfsd','dsgdg']"></ngx-select> src/index.html <!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>TestProj</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body>
<app-root></app-root>
</body>
</html> Build: optimistex@main-ubuntu:/data/www/tmp/test-proj$ ng build
Date: 2018-02-02T14:15:50.170Z
Hash: 184cb1c793e18eafe21e
Time: 7350ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 6.85 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 201 kB [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.4 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.41 MB [initial] [rendered] |
I am still getting this error, please check this out: https://drive.google.com/file/d/1Wy2-xXuN3jkx2GIe-tsPQ_VaM6z4hwsh/view |
I have imported the NgxSelectModule in a shared module. |
I have managed to get the error: Error: StaticInjectorError(AppModule)[NgxSelectComponent -> DomSanitizer]:
StaticInjectorError(Platform: core)[NgxSelectComponent -> DomSanitizer]:
NullInjectorError: No provider for DomSanitizer!
at _NullInjector.get (core.js:994)
at resolveToken (core.js:1292)
at tryResolveToken (core.js:1234)
at StaticInjector.get (core.js:1102)
at resolveToken (core.js:1292)
at tryResolveToken (core.js:1234)
at StaticInjector.get (core.js:1102)
at resolveNgModuleDep (core.js:10837)
at NgModuleRef_.get (core.js:12070)
at resolveDep (core.js:12560) Currently, I am working on it... |
Sounds good. Thanks. |
I did figure out a solution. The issue appearing when a package installed by
"defaults": {
"styleExt": "css",
"component": {},
"build": {
"preserveSymlinks": true
}
} |
--preserve-symlinks
Issue still exist :) |
I have used ng serve --preserve-symlinks |
Can you make some project for example with the bug? Maybe a little example on the planker!? |
I'm seeing the same issue, not with an ngx component, my own pipe. I'm not using ng serve. I do an ng build and then serve my app via an Express server. The app itself is too big to even think about posting on here, but I have chanced upon something which I just don't understand. A colleague pulled the same codebase out of GIT and did a clean/build on everything (we're using yarn/lerna), and she does not see the same issue. I guess there is a chance that she is running slightly different versions of something (a dependency), but we try to use absolute versions in all package.json files (rather than pushing them into git), so it is unlikely. I've also tried running in a different browser, wondering whether something was cached, but no luck. I'm starting to think it is a timing/synchronisation thing although that is a guess based on very little evidence. btw I have enabled the --preserve-symlinks setting in my angular cli json. I also know it is definitely the one component which is the problem, as everything works if I remove that line from the HTML (a resource url pipe in this case). If I remove the pipe (| safeUrl) from that line, everything else renders, I just get an iframe hourglass for this one component and a console error saying the url is unsafe. Also the component was working fine yesterday, and it hasn't been changed (though other things have) -- edit -- I know this doesn't help with the ngx-select issue, but I copied the pipes I had created into my application code (they were previously in a separate module and referenced as a dependency in my package.json), and imported/declared them in my application module using relative paths, and it started working (again). |
StaticInjectorError[DomSanitizer]:
StaticInjectorError[DomSanitizer]:
NullInjectorError: No provider for DomSanitizer!
at NullInjector.get (core.js:923)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024)
at resolveToken (core.js:1211)
at tryResolveToken (core.js:1153)
at StaticInjector.get (core.js:1024)
at resolveNgModuleDep (core.js:10585)
at NgModuleRef.get (core.js:11806)
at resolveNgModuleDep (core.js:10585)
The text was updated successfully, but these errors were encountered: