Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49259

Error when using modals

$
0
0

@JohnCressman wrote:

I am trying to use two modals to display a terms of use and disclaimer. It works, but when I try to build for android I get the following error:

ERROR in : Type DisclaimerPage in C:/ionic/EMSPROv1/src/app/pages/disclaimer/disclaimer.page.ts is part of the declarati
ons of 2 modules: HomePageModule in C:/ionic/EMSPROv1/src/app/home/home.module.ts and DisclaimerPageModule in C:/ionic/E
MSPROv1/src/app/pages/disclaimer/disclaimer.module.ts! Please consider moving DisclaimerPage in C:/ionic/EMSPROv1/src/ap
p/pages/disclaimer/disclaimer.page.ts to a higher module that imports HomePageModule in C:/ionic/EMSPROv1/src/app/home/h
ome.module.ts and DisclaimerPageModule in C:/ionic/EMSPROv1/src/app/pages/disclaimer/disclaimer.module.ts. You can also
create a new NgModule that exports and includes DisclaimerPage in C:/ionic/EMSPROv1/src/app/pages/disclaimer/disclaimer.
page.ts then import that NgModule in HomePageModule in C:/ionic/EMSPROv1/src/app/home/home.module.ts and DisclaimerPageM
odule in C:/ionic/EMSPROv1/src/app/pages/disclaimer/disclaimer.module.ts.

If I take the imports out of the homePageModule, I get errors as well. I’m not sure what it really wants me to do here.

Any hints?

ts file

import { GetMenuService } from './../services/get-menu.service';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Routes, Router } from '@angular/router';
import { map } from 'rxjs/operators';
import { Observable } from 'rxjs';
import {ModalController, NavController} from '@ionic/angular';
import { GoogleAnalytics } from '@ionic-native/google-analytics/ngx';
import { Storage } from '@ionic/storage';
import { AlertController } from '@ionic/angular';
import { DisclaimerPage } from '../pages/disclaimer/disclaimer.page';
import { TermsConditionsPage } from '../pages/terms-conditions/terms-conditions.page';

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage implements OnInit {
    results: Observable<any>;
    analyticsPage = 'Home';
    disclaimerAgreed = 'No';
    termsAgreed = 'No';

    dataReturned: any;

    quickCallNumber = '';


  constructor(private menuService: GetMenuService, private router: Router, private ga: GoogleAnalytics,
              public storage: Storage, public alertController: AlertController, public modalController: ModalController) { }

    async presentTerms() {
        const modal = await this.modalController.create({
            component: TermsConditionsPage
        });

        await modal.present();
    }

  async presentDisclaimer() {
      const modal = await this.modalController.create({
        component: DisclaimerPage
      });

      await modal.present();
  }

  ngOnInit() {
        this.analyticsStart(this.analyticsPage);
        console.log('ngOnInit');
        this.results = this.menuService.getMenu2('menu1');
        console.log(this.results);

        this.storage.get('quickCallNumber').then((val) => {
              console.log('quickCallNumber', val);
              if (val === null || val === '') {
                this.storage.set('quickCallNumber', '610-973-1625');
                this.quickCallNumber = '610-973-1625';
              } else {
                this.quickCallNumber = val;
              }
        });

        this.storage.get('termsAgreed').then((val) => {
          console.log('termsAgreed', val);
          if (val === null || val === '') {
              this.termsAgreed = 'No';
          } else {
              this.termsAgreed = val;
          }
          if (this.termsAgreed === 'No') {
              this.presentTerms();
          }
        });

        this.storage.get('disclaimerAgreed').then((val) => {
            console.log('disclaimerAgreed', val);
            if (val === null || val === '') {
                  this.disclaimerAgreed = 'No';
            } else {
                  this.disclaimerAgreed = val;
            }
            if (this.disclaimerAgreed === 'No') {
              this.presentDisclaimer();
            }
        });
  }

    // Go to a specific url
    goToLink(url: string) {
      console.log('goToLink', url);
      window.open(url, '_blank');
    }
    // Dial phone number by using TEL
    dialNumber(phone: string) {
        console.log('goToPhone', phone);
        this.analyticsTrack('Dial Number', phone);
        window.open('tel://' + phone, '_blank');
    }

    // ---------------------------------------------------------------
    // ---------------------------------------------------------------
    // GOOGLE ANALYTICS
    // ---------------------------------------------------------------
    // ---------------------------------------------------------------
    analyticsStart(value) {
        this.ga.startTrackerWithId('UA-142662811-2')
            .then(() => {
                console.log('Google analytics is ready now');
                this.ga.trackView(value + ' Screen');
                // Tracker is ready
                // You can now track pages or set additional information such as AppVersion or UserId
                this.analyticsTrack('Page', 'View');
            })
            .catch(e => console.log('Error starting GoogleAnalytics', e));
    }
    analyticsTrack(event, label) {
        this.ga.trackEvent(this.analyticsPage, event, label, 1);
    }

}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49259

Trending Articles