I generated a new page in ionic 3 using the generate command. When I try adding it to the app module it throws the following error,
Uncaught Error: Unexpected value 'NewTodo' declared by the module 'AppModule'. Please add a @Pipe/@Directive/@Component annotation.
Previously while using ionic 2.x I never added annotations manually. Any idea how I can resolve it?
UPDATE
new-todo.ts file
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import {Data} from '../../providers/data';
import { ToastController } from 'ionic-angular';
@Component({
selector: 'page-new-todo',
templateUrl: 'new-todo.html',
})
class Todo {
public title: string;
public completed: boolean;
constructor() {
this.title = '';
this.completed = false;
}
}
export class NewTodo {
todo: Todo;
constructor(public navCtrl: NavController, public navParams: NavParams,public _data: Data,public toastCtrl: ToastController) {
this.todo = new Todo();
}
ionViewDidLoad() {
console.log('ionViewDidLoad NewTodo');
}
save(){
var key = this._data.save(this.todo);
if(key){
// console.log('saved');
let toast = this.toastCtrl.create({
message: '',
duration: 3000
});
toast.onDidDismiss(() => {
this.navCtrl.pop();
console.log('toast dismissed');
});
// this.navCtrl.present(toast);
toast.present();
}
}
}
app-module.ts file
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { NewTodo } from '../pages/new-todo/new-todo';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { HttpModule } from '@angular/http';
import { AngularFireModule } from 'angularfire2';
import {Data} from '../providers/data';
import * as firebase from 'firebase';
// AF2 Settings
export const firebaseConfig = {
apiKey: "AIzaSyBiVsxqjSlsPpcHCzJi0anzInr2N9FLv5E",
authDomain: "test-project-5f51f.firebaseapp.com",
databaseURL: "https://test-project-5f51f.firebaseio.com",
storageBucket: "test-project-5f51f.appspot.com",
messagingSenderId: "341872568316"
};
// firebase.initializeApp(firebaseConfig)
@NgModule({
declarations: [
MyApp,
HomePage,
NewTodo
],
imports: [
BrowserModule,
HttpModule,
IonicModule.forRoot(MyApp),
AngularFireModule.initializeApp(firebaseConfig)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage,
NewTodo
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
[Data]
]
})
export class AppModule {}
UPDATE-2
new-todo.module.ts file
import { NgModule } from '@angular/core';
import { IonicModule } from 'ionic-angular';
import { NewTodo } from './new-todo';
@NgModule({
declarations: [
NewTodo,
],
imports: [
IonicModule.forChild(NewTodo),
],
exports: [
NewTodo
]
})
export class NewTodoModule {}