I've gone through this post (and this one as well) to find a solution to my problem.
I want to ignore these errors:
Property 'payload' does not exist on type 'Matatu'.
Property 'key' does not exist on type 'Matatu'.
I've tried declaring variables to 'override' the type system, but it hasn't worked.
Here is my .ts code, and what I've attempted so far:
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, ActionSheetController } from 'ionic-angular';
import { AngularFireList, AngularFireDatabase } from 'angularfire2/database';
import { Matatu } from '../../models/matatu/matatu.interface';
/* imports */
declare var payload;
declare var key;
@IonicPage()
@Component({
selector: 'page-owner-dash',
templateUrl: 'owner-dash.html',
})
export class OwnerDashPage {
matatuListRef$: AngularFireList<Matatu>;
matatuListAsync$: any;
constructor(public navCtrl: NavController, public navParams: NavParams, private database: AngularFireDatabase, public actionShtCrtl: ActionSheetController) {
this.matatuListRef$ = this.database.list('matatu-list');
this.matatuListAsync$ = this.matatuListRef$.snapshotChanges();
}
ionViewDidLoad() {
//stuff
}
selectMatatu(matatu: Matatu){
this.actionShtCrtl.create({
title: `${matatu.payload.val().matNumberPlate}`,
buttons: [
{
text: 'Edit',
handler: () => {
//stuff
}
},
{
text: 'Delete',
role: 'destructive',
handler: () => {
this.matatuListRef$.remove(matatu.key);
}
},
{
text: 'Cancel',
role: 'cancel',
handler: () => {
//do something
}
}
]
}).present();
}
}
Here's the Matatu structure:
export interface Matatu {
$key?: string;
matNumberPlate: string;
matSacco: string;
matDriver: string;
matAccessCode: string;
matStatus: string;
matTracker: string;
matLocation: string;
}
How do I cast the property to any type?
Matatutype?