jeudi 10 novembre 2016

Angular 2 Test gets error

I have a Angular 2 component which is work fine but when I run this code ng test to pass all tests I get the followind error message :

 Can't bind to 'ngModel' since it isn't a known property of 'mdl-textfield'.                                                                           
    1. If 'mdl-textfield' is an Angular component and it has 'ngModel' input, then verify that it is part of this module.                                 
    2. If 'mdl-textfield' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message.      
     ("ditedIndex !== i"></span>                                                                                                             
                        <mdl-textfield *ngIf="editedIndex === i" [ERROR ->][(ngModel)]="roles[i].name" class="full-width" value=></mdl-textfi

eld>

here is my HTML :

<tr *ngFor="let role of roles; let i = index;" (click)="doSelect(role, i)">
            <td class="table-id"></td>
            <td>
                <span *ngIf="editedIndex !== i"></span>
                <mdl-textfield *ngIf="editedIndex === i" [(ngModel)]="role.name" class="full-width" value=></mdl-textfield>
            </td>
            <td>
                <span *ngIf="editedIndex !== i"></span>
                <mdl-textfield *ngIf="editedIndex === i" [(ngModel)]="role.description" class="full-width" value=></mdl-textfield>
            </td>
            <td>
                <button *ngIf="editedIndex === i" mdl-button mdl-button-type="mini-fab" mdl-colored="primary" (click)="doSave($event)"
                    mdl-ripple><mdl-icon>edit</mdl-icon></button>
                <button *ngIf="editedIndex === i" mdl-button mdl-button-type="mini-fab" mdl-colored="accent" (click)="doDelete($event, i)"
                    mdl-ripple><mdl-icon>remove</mdl-icon></button>
            </td>
        </tr>

Role is a model with 2 properties.

Why it works fine in runtime but it's failed in test!!

Aucun commentaire:

Enregistrer un commentaire