ambitiousmind
ambitiousmind

Reputation: 15

Cant resolve all parameters

Hi I am building a toDo app and i ran into this problem after i completed all of the steps.

error--- Runtime Error Can't resolve all parameters for TaskListPage: ([object Object], ?). Stack

import { Component } from '@angular/core';
import { NavController, ItemSliding } from 'ionic-angular';
import {Task} from './task';
import {AngularFire, FirebaseListObservable} from 'angularfire2';

@Component({
selector: 'page-tasklist',
templateUrl: 'tasklist.html'
}    )
export class TaskListPage {
tasks: FirebaseListObservable <any[]>;

constructor(public navCtrl: NavController, af: AngularFire) {
    this.tasks = af.database.list('/tasks');
}

addItem() {let theNewTask: string = prompt("New Task"); 
if (theNewTask !== '') 
        { this.tasks.push({ title: theNewTask, status: 'open'}); 

        }
}
markAsDone( slidingItem: ItemSliding, task: Task) 
    { this.tasks.update(task.$key, {status: 'done'}); 
      slidingItem.close();
    }

removeTask(slidingItem: ItemSliding, task: Task) 
{ this.tasks.remove(task.$key);
  slidingItem.close();
}


}

Upvotes: 0

Views: 175

Answers (1)

RmxPatrick
RmxPatrick

Reputation: 171

This is a place where Angular can really improve its error messaging. The offending line is this one:

constructor(public navCtrl: NavController, af: AngularFire) {

You have no access modifier on the af variable, so it is assumed to be a call-time variable (no public, protected or private, so Angular does not know it is supposed to be a class member variable). Since at compile time, what af will be is not known, it results in that warning.

The simple solution is: add an access modifier on the variable. If it is not meant to be shared, private is usually the appropriate modifier.

Also, AngularFire does not look like a valid export from angularfire2. It looks like it should be either AngularFirestore or one of the functionality specific modules - auth, messaging, etc. Also make sure you have set up your AngularFireModule in your app.module, by following the setup directions in their repo.

Upvotes: 1

Related Questions