- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我有一个组件,它接收组件的组件类以动态创建为子组件。
let componentFactory = this.componentFactoryResolver.resolveComponentFactory(componentToCreate);
this.componentReference = this.target.createComponent(componentFactory);
我正在尝试编写一个单元测试并传递一些 TestComponent 以供其创建和呈现。
TestBed
.configureTestingModule(<any>{
declarations: [MyAwesomeDynamicComponentRenderer, TestHostComponent],
entryComponents: [TestComponent],
});
因为 configureTestingModule
期望没有 entryComponents
的 TestModuleMetadata
但我得到错误:“没有组件工厂找到 TestComponent”。
如何向 TestBed
提供 entryComponents
?
最佳答案
如果你愿意,你也可以直接将它添加到你的测试文件中:
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; // DO not forget to Import
TestBed.configureTestingModule({
declarations: [ MyDynamicComponent ],
}).overrideModule(BrowserDynamicTestingModule, {
set: {
entryComponents: [ MyDynamicComponent ],
}
});
关于javascript - 为 TestBed 提供 "entryComponents",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41483841/
我正在使用 Angular Cli 创建组件。 我正在使用这个命令: ng g c DeviceComponent --module=./views/administration/Accounting
我想从组件加载模态。在 Angular Material 文档中,编写了在 entryComponents 中添加模态组件: 这个: @NgModule({ imports: [ Comm
我正在使用 Angular 8,我想在我的项目中延迟加载对话框。执行此操作时出现以下错误:- No component factory found for EditProfileComponent.
import {Component} from '@angular/core'; import {IonicPage, NavController, NavParams} from 'ionic-an
我有一个代码: ////////////////login.module.ts import { NgModule } from '@angular/core'; import { IonicPage
我有 ngx-bootstrap 模态组件。此模式在 shared 文件夹中使用。我在我的 DashboardModule 中使用这个 FirstModalComponent,例如: // Dashb
您好,我是 angular2 和 typescript 的新手。我正在动态加载组件,我想知道是否有一种方法可以使用模块的“声明”和“entryComponents”中的服务来声明我的组件。 使用 ty
例如,假设您有以下组件: import { Another } from "./Another"; @Component({ entryComponents: [ Anothe
这里我有一个方法“confirmSth”,动态加载了一个组件“SnackCheckBoxComponent”。 我想知道我是否可以在我的 OrderDetailComponent 中获取一些消息来区分
我有以下一段 Angular 代码: dashboard.component.ts import {Component, AfterViewInit, ComponentFactoryResolver
我的 app.module.ts 中有这个: import { BrowserModule } from '@angular/platform-browser'; import { ErrorHand
我有一个组件,它接收组件的组件类以动态创建为子组件。 let componentFactory = this.componentFactoryResolver.resolveComponentFact
我在 Angular 6 中使用 ng-bootstrap 模态时遇到问题。 首先,我有 2 个模块: AppModule 和 ComponentModule 这是ComponentModule: @
我在 Angular 6 中使用 ng-bootstrap 模态时遇到问题。 首先,我有 2 个模块: AppModule 和 ComponentModule 这是ComponentModule: @
我制作了一个弹出组件,它可以动态加载内容组件,而不管类型如何。在 RC4 之后,如果不将组件添加到 entryComponents 列表中是不可能注入(inject)组件的。 是否可以加载组件而不在
当我创建一个新的页面组件时,我现在必须将它放在声明和 entryComponents 数组中。为什么它必须在两个地方? 例如,我刚刚创建了一个新的 login.page.ts 文件,但我必须在声明和
在将 ag-grid 与 angular4 一起使用时,我遇到了以下错误消息。 我试图在通过 HTTP 获取 json 后显示行数据。 this.gridOptions.api.setRowData(
我正在尝试关注 https://material.angular.io/components/component/dialog 上的文档但我不明白为什么会出现以下问题? 我在组件中添加了以下内容: @
我正在开发一个依赖于 angular 2 的 Ionic 应用程序 ( 2.0.0-rc0 )。所以引入了新的ngModules。我正在下面添加我的 app.module.ts.。 import {
谁能清楚地解释为什么在 IVY 编译器中,入口组件 API 不再需要了?换句话说,发生了什么变化内部 所以Angular突然不需要提醒你要动态创建组件 最佳答案 View 引擎 在 Ivy 之前, V
我是一名优秀的程序员,十分优秀!