我通常更喜欢使用--no-site-packages选项创建virtualenvs以获得更多隔离,并且因为默认的python全局包包含相当多的包,并且通常不需要大多数包.但是我仍然希望在全局中保留一些选择包,比如PIL或psycopg2.是否有一种很好的方法将它们包含在virtualenv中,也可以轻松实现自动化?
我们提供了一种从API延迟加载和设置Angular应用程序的LOCALE_ID的方法(通过在启动时加载用户配置文件数据)。这在Angular 7上效果很好,但是当我升级到Angular 8时,它停止了工作。调用localeFactory时(参见下文)localeService.getLocale()
,它是未定义的,尚未被初始化。我们将初始化SharedResolver
为,SharedModule
其中的包含在的中,其中包含在中AppModule
。在Angular 8中执行此操作的正确方法是什么?在更改文档中没有看到与此相关的任何内容,因此我想这是间接的。我在这里应该采取什么方法的任何意见?谢谢
请参见下面的相关代码:
app.module.ts
export function localeFactory(localeService: LocaleService) {
console.log('locale factory called');
// This is `undefined` here now for some reason
console.log(localeService.getLocale());
return localeService.getLocale() || 'en';
}
...
const APP_LOCALE_ID = {
provide: LOCALE_ID,
deps: [LocaleService],
useFactory: localeFactory
};
@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpClientModule,
BrowserAnimationsModule,
AppRoutingModule,
SharedModule.forRoot(), // <- in this module we have the SharedResolver
AccountModule,
ApiModule,
GenesysSubprojectModule
],
declarations: [AppComponent],
providers: [
AppRouteGuard,
BreadcrumbService,
{
provide: APP_INITIALIZER, …
Run Code Online (Sandbox Code Playgroud) 我是 Angular 应用程序单元测试的新手,我正在尝试测试我的第一个组件。实际上,我正在尝试测试实际组件使用的抽象基类,因此我在我的规范中基于它创建了一个简单的组件,并使用它来测试它。但是有一个处理 ( Injector
)依赖项,我没有正确地将它存根,因为当我尝试运行测试时,我收到此错误:
Can't resolve all parameters for TestFormInputComponentBase
但我不确定我错过了什么?这是规范:
import { GenFormInputComponentBase } from './gen-form-input-component-base';
import { Injector, Component } from '@angular/core';
import { TestBed } from '@angular/core/testing';
// We cannot test an abstract class directly so we test a simple derived component
@Component({
selector: 'test-form-input-component-base'
})
class TestFormInputComponentBase extends GenFormInputComponentBase {}
let injectorStub: Partial<Injector>;
describe('GenFormInputComponentBase', () => {
let baseClass: TestFormInputComponentBase;
let stub: Injector;
beforeEach(() => {
// stub Injector for test purpose
injectorStub = …
Run Code Online (Sandbox Code Playgroud) 我已经实现了使用PrimeNG TurboTable和NgRx的自定义Grid组件,并使用内置的TurboTable虚拟滚动条为其添加了虚拟滚动条功能。这也是带有onLazyLoad
处理程序的延迟加载。但是,onLazyLoad
在滚动网格结果时调用时,会出现这种奇怪的行为。
onLazyLoad called with event.first=0 and event.rows=40
onLazyLoad called with event.first=0 and event.rows=80
onLazyLoad called with event.first=0 and event.rows=160
onLazyLoad called with event.first=0 and event.rows=320
onLazyLoad called with event.first=0 and event.rows=640
onLazyLoad called with event.first=0 and event.rows=1280
Run Code Online (Sandbox Code Playgroud)
所以有两个问题:
event.first
始终保持0 event.rows
不断增加到很高的值我以为这是PrimeNG中的错误,但是当我尝试使用简单的StackBlitz重现它时,它的行为就正确了。 https://stackblitz.com/edit/github-primeng-virtualscroll-issue
我在StackBlitz上看到了这一点:
loadDataOnScroll is called with event.first=0 and event.rows=40
loadDataOnScroll is called with event.first=20 and event.rows=40
loadDataOnScroll is called with event.first=40 and event.rows=40
loadDataOnScroll is called with event.first=80 and event.rows=40
loadDataOnScroll is …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在应用程序启动时设置Hangfire经常性作业,但是在该作业中,如果我尝试使用IRepository
Injection,它将在尝试执行查询时给出与DbContext相关的错误:
System.ObjectDisposedException
Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. Object name: 'WsApplicationDbContext'. …
Run Code Online (Sandbox Code Playgroud) angular ×3
.net-core ×1
angular8 ×1
c# ×1
easy-install ×1
hangfire ×1
jasmine ×1
lazy-loading ×1
localization ×1
mocking ×1
ngrx ×1
pip ×1
primeng ×1
python ×1
unit-of-work ×1
unit-testing ×1
virtualenv ×1