当我在 angular 8 项目中运行单元测试时,我在 ngx-toastr 中发现了一个错误
NullInjectorError: StaticInjectorError(DynamicTestModule)[ToastrService -> InjectionToken ToastConfig]:
我在spec.ts文件中导入了requierd模块,并且我还在app.module.ts中声明了forRoot()
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [MatTabsModule,
ReactiveFormsModule,
MatTooltipModule,
HttpClientTestingModule,
RouterTestingModule,
ToastrModule
],
declarations: [CommunicationComponent],
providers: [
ToastrService,
]
})
.compileComponents();
Run Code Online (Sandbox Code Playgroud)
}));
嗨,我正在使用打字稿在 angular 6 中实现 Ngx-toastr,我的问题是我无法让它变得漂亮,因为我不知道在那个ngx-toastr类上覆盖了哪个 css我在Style上写了一些 css 。 css文件ngx-toastr并且我想要border-radius: 15px;但内部部分没有采用圆角border-radius: 15px;我从互联网上搜索了许多资源但没有得到正确的输出我无法更改其他 toastr 因为在我的项目中大约有350+ 组件我不想要使用方法更改每个文件,这就是为什么我想自定义现有的 toastr CSS。
这是我的 CSS 代码
.toast-container .ngx-toastr {
position: relative;
overflow: hidden;
margin: 0 0 6px;
padding: 15px 15px 15px 50px;
width: 300px;
border-radius: 15px !important;
background-position: 15px center;
background-repeat: no-repeat;
background-size: 24px;
box-shadow: 0 0 12px #999;
color: #fff;
border-image-source: linerar-gradient(red,purple) !important;
border: 4px solid green !important;
border-image-source: linear-gradient(red, purple) !important;
border-image-slice: …Run Code Online (Sandbox Code Playgroud) ./src/app/nav/nav.component.ts:5:0-44 - 错误:找不到模块:错误:包路径 ./public_api 未从包 C:\Users\Score\demo\DatingApp\client 导出\node_modules\ngx-toastr (请参阅 C:\Users\Score\demo\DatingApp\client\node_modules\ngx-toastr\package.json 中的导出字段)
./src/app/register/register.component.ts:4:0-55 - 错误:找不到模块:错误:包路径 ./toastr/toastr.service 未从包 C:\Users\Score\demo 导出\DatingApp\client\node_modules\ngx-toastr (请参阅 C:\Users\Score\demo\DatingApp\client\node_modules\ngx-toastr\package.json 中的导出字段)[1]:https://i.stack。 imgur.com/WaZNB.png
我将 ngx-toaster 与disableTimeOuttrue 一起使用。所以它不会自动隐藏。但现在,当用户离开页面时(在 ngOnDestroy 方法内),我不会以编程方式隐藏它。我该怎么做?
this.toastr.error(message, status, {disableTimeOut: true});
Run Code Online (Sandbox Code Playgroud) 错误 TS2416:类型“ToastInjector”中的属性“get”无法分配给基本类型“Injector”中的同一属性。
\n输入 \'(token: any, notFoundValue?: T, flags?: InjectFlags) => ToastPackage | T\' 不可分配给类型 \'{ (令牌:ProviderToken,notFoundValue:未定义,选项:InjectOptions & { 可选?: false; }):T;(令牌:ProviderToken,notFoundValue:null,选项:InjectOptions):T;(令牌:ProviderToken <...>,notFoundValue?:T,选项?:InjectOptions | InjectFlags):T;(令牌:ProviderToken<...>,而不是Fou...\'。
\nTypes of parameters \'flags\' and \'options\' are incompatible.\n Type \'InjectOptions & { optional?: false; }\' is not assignable to type \'InjectFlags\'.\nRun Code Online (Sandbox Code Playgroud)\ntoast-injector.ts
\nimport {Injector, InjectFlags} from \'@angular/core\xe2\x80\x99;\n\nimport { ToastPackage } from \'./toast-config\';\n\n\n\nexport class ToastRef<T> {\n\nexport class ToastInjector implements Injector {\n\n constructor (\n\n private _toastPck: ToastPackage,\n\n private _parntInjtr: Injector\n\n ) {}\n\n\n //eslint-disable-next-line\n\n get<T> …Run Code Online (Sandbox Code Playgroud)