无法绑定到 'value',因为它不是已知的 属性 angular 组件
can't bind to 'value' since it isn't a known property angular component
我的组件测试用例失败并抛出错误错误:模板解析错误:无法绑定到 'video',因为它不是 'app-video-card' 的已知 属性 .
这里,在我的组件中
<app-video-card class="bs-video-card" *ngFor="let video of videos" [video]="video"></app-video-card>
我已经在测试文件中声明了我的组件。
@Component({ selector: 'app-video-card', template: '' })
class VideoCardStuBComponent { }
describe('VideosComponent', () => {
let component: VideosListComponent;
let fixture: ComponentFixture<VideosListComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, HttpClientTestingModule
],
declarations: [ VideosListComponent, VideoCardStuBComponent ],
providers: [HomeConstants,
{provide: SqVideoExportService},
DatePipe],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(VideosListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
由于您正在为 <app-video-card>
使用存根,因此您还需要在那里定义 video
输入。
@Component({ selector: 'app-video-card', template: '<div></div>' })
class VideoCardStuBComponent {
@Input() video;
}
我的组件测试用例失败并抛出错误错误:模板解析错误:无法绑定到 'video',因为它不是 'app-video-card' 的已知 属性 .
这里,在我的组件中
<app-video-card class="bs-video-card" *ngFor="let video of videos" [video]="video"></app-video-card>
我已经在测试文件中声明了我的组件。
@Component({ selector: 'app-video-card', template: '' })
class VideoCardStuBComponent { }
describe('VideosComponent', () => {
let component: VideosListComponent;
let fixture: ComponentFixture<VideosListComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule, HttpClientTestingModule
],
declarations: [ VideosListComponent, VideoCardStuBComponent ],
providers: [HomeConstants,
{provide: SqVideoExportService},
DatePipe],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(VideosListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
由于您正在为 <app-video-card>
使用存根,因此您还需要在那里定义 video
输入。
@Component({ selector: 'app-video-card', template: '<div></div>' })
class VideoCardStuBComponent {
@Input() video;
}