Drew
Drew

Reputation: 1361

Angular "Must be imported or local" error

I am trying to create an ionic application, and when I go to link pages together in the ionic creator, I am getting an error on the .ts file as follows:

 typescript: src/pages/home/home.ts, line: 4 
            Individual declarations in merged declaration 'HomePage' must be all exported or all local. 

       L3:  import { NotificationsPage } from '../notifications/notifications';
       L4:  import { HomePage } from '../home/home';
       L5:  import { MyPatientsPage } from '../my-patients/my-patients';

Below is the code from my .ts file:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { NotificationsPage } from '../notifications/notifications';
import { HomePage } from '../home/home';
import { MyPatientsPage } from '../my-patients/my-patients';
import { AllPatientsPage } from '../all-patients/all-patients';
import { LoginPage } from '../login/login';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController) {
  }
  goToNotifications(params){
    if (!params) params = {};
    this.navCtrl.push(NotificationsPage);
  }goToHome(params){
    if (!params) params = {};
    this.navCtrl.push(HomePage);
  }goToMyPatients(params){
    if (!params) params = {};
    this.navCtrl.push(MyPatientsPage);
  }goToAllPatients(params){
    if (!params) params = {};
    this.navCtrl.push(AllPatientsPage);
  }goToLogin(params){
    if (!params) params = {};
    this.navCtrl.push(LoginPage);
  }
}

Upvotes: 2

Views: 11911

Answers (1)

Sampath
Sampath

Reputation: 65870

You must not import the HomePage inside the home.ts file.i.e. Line 4

Need to remove below import from the home.ts file

import { HomePage } from '../home/home';

Upvotes: 6

Related Questions