模板解析错误angular5 karma Jasmine2.8.0

时间:2018-04-29 12:27:45

标签: angular karma-jasmine angular5

我的Angular 5页面运行得非常好。但是在运行测试用例时,我得到了下面提到的错误。

Failed: Template parse errors:
    Can't bind to 'images' since it isn't a known property of 'angular-image-slider'.
    1. If 'angular-image-slider' is an Angular component and it has 'images' input, then verify that it is part of this module.
    2. If 'angular-image-slider' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
      <div class="foot">
       <h4 class="lower-headings">Peer Group</h4>
      <angular-image-slider [ERROR ->][images]="imagesUrl" style="height:70%"></angular-image-slider> 


    "): ng:///DynamicTestModule/AppComponent.html@33:24
    'angular-image-slider' is not a known element:
    1. If 'angular-image-slider' is an Angular component, then verify that it is part of this module.
    2. If 'angular-image-slider' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
      <div class="foot">
       <h4 class="lower-headings">Peer Group</h4>
      [ERROR ->]<angular-image-slider [images]="imagesUrl" style="height:70%"></angular-image-slider> 


    "): ng:///DynamicTestModule/AppComponent.html@33:2

*。Component.html

<div class="foot">
   <h4 class="lower-headings">Peer Group</h4>
  <angular-image-slider [images]="imagesUrl" style="height:70%"></angular-image-slider> 
  </div>

*。module.ts

import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
import { FinanceserviceService } from './financeservice.service';
import { NgModule,CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { AppComponent } from './woodside.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { SliderModule } from 'angular-image-slider';
import { CommonModule } from '@angular/common';


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    BrowserAnimationsModule,
    SliderModule,
  ],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  providers: [FinanceserviceService],
  bootstrap: [AppComponent]
})

export class AppModule { }

*。component.ts

export class AppComponent {
  title = 'XXXXXXXXX';
  chart = [];
  imagesUrl=[
    'assets/1.jpg',
    'assets/2.png',
    'assets/3.jpg',
    'assets/4.jpg'
    ];
}

抱歉这个愚蠢的问题。我是棱角分明的新人并试图纠正错误。

1 个答案:

答案 0 :(得分:0)

  1. 您必须在测试规范中导入SliderModule

    或者

  2. 如果您正在测试不包含angular-image-slider标记的组件(可能存在于子组件中),请在测试配置中添加schemas: [NO_ERRORS_SCHEMA]。这应该可以解决错误。

相关问题