Ionic 2 응용 프로그램에 대한 https://angular-meteor.com/tutorials/whatsapp2/ionic/chats-page의 자습서를 따르고 있습니다. 나는 오류가 나는 다음과 같은 코드를 추가 할 때 :Ionic 2 오류 : Typescript 오류 제공된 매개 변수가 호출 대상의 서명과 일치하지 않습니다.
removeChat(chat: Chat): void {
this.chats = this.chats.map<Chat[]>(chatsArray => {
const chatIndex = chatsArray.indexOf(chat);
chatsArray.splice(chatIndex, 1);
return chatsArray;
});
}
이 기능은
<ion-content class="chats-page-content">
<ion-list class="chats">
<ion-item-sliding *ngFor="let chat of chats | async">
<button ion-item class="chat">
<img class="chat-picture" [src]="chat.picture">
<div class="chat-info">
<h2 class="chat-title">{{chat.title}}</h2>
<span *ngIf="chat.lastMessage" class="last-message">
<p *ngIf="chat.lastMessage.type == 'text'" class="last-message-content last-message-content-text">
{{chat.lastMessage.content}}
</p>
<span class="last-message-timestamp">{{chat.lastMessage.createdAt | amCalendar }}</span>
</span>
</div>
</button>
<ion-item-options class="chat-options">
<button ion-button color="danger" class="option option-remove" (click)="removeChat(chat)">Remove</button>
</ion-item-options>
</ion-item-sliding>
</ion-list>
확실하지 "옵션-제거"클래스와 버튼에 클릭 이벤트에서 호출되고 오류 메시지의 정확성은 어느 정도입니까? this.chats.map<Chat[]>(chatsArray => {
에 문제가있는 것으로 보입니다.
'this.chats'는 객체 또는 배열의 배열입니까? –
그것은 객체의 배열입니다 – helenkitt
@helenkitt 문제를 재현 할 수 없습니다 ... 링크와 같이 올바르게 모든 것을 설정했는지 확인하십시오. 해결할 수 없다면, plunker로 문제를 재현 해보십시오 : – Alex