не может связываться со значением, так как это не известное свойство angular компонент - PullRequest
0 голосов
/ 27 апреля 2020

мой тестовый пример не выполняется для моего компонента и выдает ошибку. Ошибка: ошибки синтаксического анализа шаблона: невозможно связать с «видео», поскольку оно не является известным свойством «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();
  });

});

1 Ответ

1 голос
/ 27 апреля 2020

Поскольку вы используете заглушку для <app-video-card>, вам также необходимо определить вход video.

@Component({ selector: 'app-video-card', template: '<div></div>' })
class VideoCardStuBComponent {
  @Input() video;
}
...