실패 : 템플릿 구문 분석 오류 : 'a'의 알려진 속성이 아니므로 'routerLink'에 바인딩 할 수 없습니다. ( "s ="navbar-nav ">

K.Nehe

각도로 테스트를 시작하지만 처음으로 ng 테스트를 실행 한 후 얻은 것입니다. 테스트를 추가하지 않았습니다.

 Failed: Template parse errors:
    Can't bind to 'routerLink' since it isn't a known property of 'a'. ("s="navbar-nav" >
                <li class="list-item" style="margin-top:20px;">
                        <a [ERROR ->][routerLink]="[{ outlets: {rightdiv: ['addProduct'] } }]" skipLocationChange>
                           "): ng:///DynamicTestModule/ManageProductsComponent.html@17:23
    Can't bind to 'icon' since it isn't a known property of 'fa-icon'.
    1. If 'fa-icon' is an Angular component and it has 'icon' input, then verify that it is part of this module.
    2. If 'fa-icon' 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. ("]="[{ outlets: {rightdiv: ['addProduct'] } }]" skipLocationChange>
                            <fa-icon [ERROR ->][icon]="faBook" size="2x" class="icon"></fa-icon>
                            Add Product
                   "): ng:///DynamicTestModule/ManageProductsComponent.html@18:33
    'fa-icon' is not a known element:
    1. If 'fa-icon' is an Angular component, then verify that it is part of this module.
    2. If 'fa-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("outerLink]="[{ outlets: {rightdiv: ['addProduct'] } }]" skipLocationChange>
                            [ERROR ->]<fa-icon [icon]="faBook" size="2x" class="icon"></fa-icon>
                            Add Product
          "): ng:///DynamicTestModule/ManageProductsComponent.html@18:24
    Can't bind to 'routerLink' since it isn't a known property of 'a'. ("
                </li>
            <li class="list-item" style="margin-top: 10px;">
                <a [ERROR ->][routerLink]="[{ outlets: {rightdiv: ['']} }]" skipLocationChange>
                <fa-icon [icon]="faEdi"): ng:///DynamicTestModule/ManageProductsComponent.html@23:15
    Can't bind to 'icon' since it isn't a known property of 'fa-icon'.
    1. If 'fa-icon' is an Angular component and it has 'icon' input, then verify that it is part of this module.
    2. If 'fa-icon' 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. ("         <a [routerLink]="[{ outlets: {rightdiv: ['']} }]" skipLocationChange>
                <fa-icon [ERROR ->][icon]="faEdit" size="2x" class="icon"></fa-icon>
                    Manage Products
                </a>
아타나시오 스 카타 라스

기본 생성 단위 테스트는 spec.ts 파일에 기본적으로 포함되어 있습니다.

라우터 링크가있는 곳마다 가져 오기 섹션에 다음을 추가해야합니다.

imports: [ RouterTestingModule ]

모의 경로로 더 구체적인 테스트를 수행하려면 다음과 같이 구성 할 수 있습니다.

describe('component: TestComponent', function () {
  beforeEach(() => {
    TestBed.configureTestingModule({
      imports: [
        CommonModule,
        RouterTestingModule.withRoutes([
         { path: '', component: OtherTestComponent }
        ])
      ],
      declarations: [ TestComponent, OtherTestComponent, MockFaIconComponent  ]
    });
  });
});

또한 fa-icon 구성 요소 또는이를 포함하는 모듈 또는 모의 fa-icon 구성 요소를 선언해야합니다.

@Component({
  selector: 'fa-icon',
  template: '<p>Mock fa icon Component</p>'
})
class MockFaIconComponent {
   @Input()
   icon: any;
}

당신의 삶을 더 쉽게 만들어 줄 모의 컴포넌트 구현도 있습니다. ng-mocks

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관