AngularFire2: you are using the development build of the firebase SDK - google-cloud-firestore

So i'm using the official documentation to setup and install angularfire2.
https://github.com/angular/angularfire2/blob/master/docs/install-and-setup.md
This works fine, my data is coming in but when building for production i get this error:
It looks like you're using the development build of the Firebase JS
SDK. When deploying Firebase apps to production, it is advisable to
only import the individual SDK components you intend to use.
For the CDN builds, these are available in the following manner
(replace with the name of a component - i.e. auth, database,
etc):
I tried every suggestion out there but nothing is working.
Any Ideas?
thx,
Root module
import { NgModule } from '#angular/core';
import { RouterModule } from '#angular/router';
import { NoopAnimationsModule } from '#angular/platform-browser/animations';
import { RootComponent } from './rootComponent.component';
import { ROOT_ROUTES } from './root.routes';
import { BrowserModule, Title } from '#angular/platform-browser';
import { AngularFireModule } from '#angular/fire';
import { AngularFirestoreModule } from '#angular/fire/firestore';
import { environment } from '../environments/environment';
#NgModule({
declarations: [RootComponent],
imports: [
AngularFireModule.initializeApp(environment.firebase),
AngularFirestoreModule,
NoopAnimationsModule,
BrowserModule,
RouterModule.forRoot(ROOT_ROUTES)
],
providers: [Title],
bootstrap: [RootComponent]
})
export class RootModule {}
Component
import { Component, OnInit } from '#angular/core';
import { MatTableDataSource } from '#angular/material';
import { AngularFirestore } from '#angular/fire/firestore';
import { Observable } from 'rxjs';
import { ActivatedRoute } from '#angular/router';
import { Seal } from '../seals.types';
import { StudioService } from '../../../service/studio.service';
#Component({
selector: 'seals-component',
templateUrl: './seals.component.html'
})
export class SealsComponent implements OnInit {
constructor(private db:AngularFirestore, private studioService: StudioService) {
this.getData();
}
items: Observable<any[]>;
dataSource = new MatTableDataSource<Seal[]>();;
displayedColumns: string[] = ['description', 'language', 'seal', 'type'];
pID:string = 'flsjezlijlsfj';
ngOnInit() {}
getData() {
this.items = this.db.collection(`sealsDB/TNDorQMQOzoqY6P6Ej0i/seal/${this.pID}/seal/`).valueChanges();
this.items.subscribe(seals => {
this.dataSource.data = seals
})
}
}

I was having the same warning and it took me a while to figure it out that I was using the User interface from firebase/auth, along with Timestamp.fromDate() in other file.
So I added:
import * as firebase from 'firebase/app';
import { User } from 'firebase/auth';
and just
import * as firebase from 'firebase/app';
where I used
firebase.firestore.Timestamp.fromDate()
This got rid of the warning.

Related

How to access provider members within a component in Ionic 4

I have a provider having a method getWeather() and I want to call it from home component. When I am trying to call getWeather() from home component I am getting error in console like: ERROR TypeError: Cannot read property 'getWeather' of undefined
weather.ts
import { Http } from '#angular/http';
import { Injectable } from '#angular/core';
import "rxjs/add/operator/map";
#Injectable()
export class WeatherProvider {
constructor(public http: Http) {
console.log('Hello WeatherProvider Provider: ');
}
getWeather() {
return this.http.get('https://samples.openweathermap.org/data/2.5/forecast?q=London,us&appid=b6907d289e10d714a6e88b30761fae22').map(res=>res.json());
}
}
home.ts
import { Component } from '#angular/core';
import { NavController } from 'ionic-angular';
import { WeatherProvider } from "../../providers/weather/weather";
//import { HttpModule } from "#angular/http";
#Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
weather:any;
constructor(public navCtrl: NavController, private wp:WeatherProvider) {
}
ionViewWillEnter() {
this.weather.getWeather().subscribe(weather=>{
console.log(weather)
})
}
}
The error is gone after restarting the ionic dev server. I don't know why the ionic is behaving like this.

How to implement rating in ionic 3?

How do I create 5 star rating in ionic 3, I visited https://github.com/andrucz/ionic2-rating but it is not working. Also read some tutorial but not found anything clean and clear for ionic 3.
Just for clear, I want to get rating value and display rating.
Any help would be appreciated.
Thankyou
Demo: https://stackblitz.com/edit/ionic3-star-rating
Use github.com/melwinVincent/ionic3-star-rating npm package.
Step 1. Add the ionic3-star-rating component in your page (parent component) as follows
<ionic3-star-rating
activeIcon = "ios-star"
defaultIcon = "ios-star-outline"
activeColor = "#488aff"
defaultColor = "#f4f4f4"
readonly="false"
[rating]="3">
</ionic3-star-rating>
Step 2.
You have to import the StarRatingModule in the module.ts of your parent component as follows
import { NgModule } from '#angular/core';
import { IonicPageModule } from 'ionic-angular';
import { ParentPage } from './parent';
import { StarRatingModule } from 'ionic3-star-rating';
#NgModule({
declarations: [
ParentPage,
],
imports: [
StarRatingModule,
IonicPageModule.forChild(ParentPage),
],
})
export class ParentPageModule {}
Step 3.
To get the changed rating in the parent component,
You need to use events from ionic package.
import { Component } from '#angular/core';
import { NavController } from 'ionic-angular';
import { Events } from 'ionic-angular';
#Component({
selector: 'page-about',
templateUrl: 'about.html'
})
export class AboutPage {
constructor(public navCtrl: NavController,
public events: Events) {
events.subscribe('star-rating:changed', (starRating) => {console.log(starRating)});
}
}

ionic serve giving error

When I am trying to run my app, it is saying
Type IonicApp is part of the declarations of 2 modules: IonicModule and AppModule! Please consider moving IonicApp to a higher module that imports IonicModule and AppModule. You can also create a new NgModule that exports and includes IonicApp then import that NgModule in IonicModule and AppModule.
How do I get rid of this error ?
Copying entire error coming in console below:
ionic-app-script task: "build"
[11:51:25] Error: Type IonicApp in F:/D/IONIC/quicktask/quicktask-web-froala -
test/node_modules/ionic-angular/components/app/app-root.d.ts is part of the declarations of 2 modules:
IonicModule in F:/D/IONIC/quicktask/quicktask-web-froala - test/node_modules/ionic-angular/module.d.ts and
AppModule in F:/D/IONIC/quicktask/quicktask-web-froala - test/src/app/app.module.ts! Please consider moving
IonicApp in F:/D/IONIC/quicktask/quicktask-web-froala -
test/node_modules/ionic-angular/components/app/app-root.d.ts to a higher module that imports IonicModule in
F:/D/IONIC/quicktask/quicktask-web-froala - test/node_modules/ionic-angular/module.d.ts and AppModule in
F:/D/IONIC/quicktask/quicktask-web-froala - test/src/app/app.module.ts. You can also create a new NgModule
that exports and includes IonicApp in F:/D/IONIC/quicktask/quicktask-web-froala -
test/node_modules/ionic-angular/components/app/app-root.d.ts then import that NgModule in IonicModule in
F:/D/IONIC/quicktask/quicktask-web-froala - test/node_modules/ionic-angular/module.d.ts and AppModule in
F:/D/IONIC/quicktask/quicktask-web-froala - test/src/app/app.module.ts.
What should I do?
app.module.ts
import { BrowserModule } from '#angular/platform-browser';
import { ErrorHandler, NgModule } from '#angular/core';
import { App, NavController, IonicErrorHandler, IonicModule,IonicApp } from 'ionic-angular'; // removed IonicApp from here
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { ListPage } from '../pages/list/list';
import { LoginPage } from '../pages/login/login';
import { NewtaskPage } from '../pages/newtask/newtask';
//import { DashboardPage } from '../pages/dashboard/dashboard';
import { TaskgivenPage } from '../pages/taskgiven/taskgiven';
import { MytaskPage } from '../pages/mytask/mytask';
import { CommunicationPage } from '../pages/communication/communication';
import { CommunicationgivenPage } from '../pages/communicationgiven/communicationgiven';
import { CommunicationreportPage } from '../pages/communicationreport/communicationreport';
import { GivencommunicationclosedPage } from '../pages/givencommunicationclosed/givencommunicationclosed';
import { TestPage } from '../pages/test/test';
import { LogoutPage } from '../pages/logout/logout';
import { MyclosedtaskPage } from '../pages/myclosedtask/myclosedtask';
import { GivenclosedtaskPage } from '../pages/givenclosedtask/givenclosedtask';
import { ReporttoPage } from '../pages/reportto/reportto';
import { SlidePage } from '../pages/slide/slide';
import { StatusBar } from '#ionic-native/status-bar';
import { SplashScreen } from '#ionic-native/splash-screen';
//import { Firebase } from '#ionic-native/firebase';
import { SpeechRecognition } from '#ionic-native/speech-recognition';
import { Headers, Http, HttpModule ,Response } from '#angular/http';
import { IonicStorageModule } from '#ionic/storage';
import { TimeAgoPipe } from 'time-ago-pipe';
import {Commopen} from '../pages/givencommunicationclosed/commopen';
import { Userimage } from '../pages/dashboard2/userimage';
import { MycommclosedPage } from '../pages/mycommclosed/mycommclosed';
import { Dashboard2Page } from '../pages/dashboard2/dashboard2';
import { MytaskuserwisePage } from '../pages/mytaskuserwise/mytaskuserwise';
import { ProfilePage } from '../pages/profile/profile';
import { PaymentPage } from '../pages/payment/payment';
import { InAppBrowser } from '#ionic-native/in-app-browser';
import { InfoPage } from '../pages/info/info';
import { PerformancePage } from '../pages/performance/performance';
import { PopoverPage } from '../pages/communicationgiven/popover';
import { Updatepopup} from '../pages/communicationgiven/updatepopup';
import { TimelinePage } from '../pages/timeline/timeline';
import { Commpopup } from '../pages/timeline/commpopup';
import {SearchPage} from '../pages/search/search';
import {SuggestionPage} from '../pages/suggestion/suggestion';
import {Mytaskpopup} from '../pages/mytask/mytaskpopup';
import {Userwisepopup} from '../pages/mytaskuserwise/userwisepopup';
import {Taskgivenpopup} from '../pages/taskgiven/taskgivenpopup';
import {Reportpopup} from '../pages/reportto/reportpopup';
import {FollowerPage} from '../pages/follower/follower';
import {CommfollowerPage} from '../pages/commfollower/commfollower';
import { CommPage } from '../pages/comm/comm';
import {ReportsPage} from '../pages/reports/reports';
import { DashmodalPage } from '../pages/dashmodal/dashmodal';
import { Dashmodal1Page } from '../pages/dashmodal1/dashmodal1';
import { LabelPage } from '../pages/label/label';
import { SortPage } from '../pages/sort/sort';
import { SortuserwisePage } from '../pages/sortuserwise/sortuserwise';
import { LastseenPage } from '../pages/lastseen/lastseen';
import { MemolistPage } from '../pages/memolist/memolist';
import { OfcmemoPage } from '../pages/ofcmemo/ofcmemo';
import { CommadminPage } from '../pages/commadmin/commadmin';
import { AdminpcPage } from '../pages/adminpc/adminpc';
import {AiPage} from '../pages/ai/ai';
import { Autosize } from '../directives/autosize/autosize';
// Import Froala Editor.
import "froala-editor/js/froala_editor.pkgd.min.js";
import { NoSanitizePipe } from '../pipes/no-sanitize/no-sanitize';
// Import Angular2 plugin.
import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
import {Nl2BrPipeModule} from 'nl2br-pipe';
import {LinkyModule} from 'angular-linky';
//Search
import { SelectSearchableModule } from 'ionic-select-searchable';
// for ionic build --prod errors or aot compilation
// import { OverlayPortal } from '../../node_modules/ionic-angular/umd/components/app/overlay-portal.d';
//import { IonicApp } from '../../node_modules/ionic-angular/umd/components/app/app-root.d';
//import { ClickBlock } from '../../node_modules/ionic-angular/umd/components/app/click-block.d';
//import { Slides } from '../../node_modules/ionic-angular/umd/components/slides/slides.d';
import { FilterArrayPipe } from '../pages/dashboard2/filterpipe';
import {IonicPage, NavParams, Slides} from 'ionic-angular';
#NgModule({
declarations: [
// OverlayPortal, //for aot compilation
// IonicApp , //for aot compilation for app-root.d
// ClickBlock, //for aot compilation
// Slides, //for aot compilation
IonicApp,
FilterArrayPipe, //for aot compilation
TimeAgoPipe,
MyApp,
HomePage,
ListPage,
LoginPage,
NewtaskPage,
// DashboardPage,
TaskgivenPage,
MytaskPage,
CommunicationPage,
CommunicationgivenPage,
CommunicationreportPage,
GivencommunicationclosedPage,
TestPage,
LogoutPage,
MyclosedtaskPage,
GivenclosedtaskPage,
ReporttoPage,
Dashboard2Page,
MytaskuserwisePage,
MycommclosedPage,
ProfilePage,
PaymentPage,
InfoPage,
SlidePage,
PerformancePage ,
PopoverPage,
Updatepopup,
SearchPage,
TimelinePage,
Commpopup,
SuggestionPage,
Mytaskpopup,
Userwisepopup,
Taskgivenpopup,
Reportpopup,
AiPage,
Autosize,
NoSanitizePipe,
FollowerPage,
CommfollowerPage,
CommPage,
ReportsPage,
DashmodalPage,
Dashmodal1Page,
LabelPage,
SortPage,
SortuserwisePage,
LastseenPage,
MemolistPage,
OfcmemoPage,
CommadminPage,
AdminpcPage,
//OverlayPortal
],
imports: [
BrowserModule,
HttpModule,
Nl2BrPipeModule,
LinkyModule,
SelectSearchableModule,
IonicModule.forRoot(MyApp),
FroalaEditorModule.forRoot(),
FroalaViewModule.forRoot(),
IonicStorageModule.forRoot()
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage,
ListPage,
LoginPage,
NewtaskPage,
// DashboardPage,
TaskgivenPage,
MytaskPage,
CommunicationPage,
CommunicationgivenPage,
CommunicationreportPage,
GivencommunicationclosedPage,
TestPage,
LogoutPage,
MyclosedtaskPage,
GivenclosedtaskPage,
ReporttoPage,
Dashboard2Page,
MytaskuserwisePage,
MycommclosedPage,
ProfilePage,
PaymentPage,
InfoPage,
SlidePage,
PerformancePage,
PopoverPage,
Updatepopup,
SearchPage,
TimelinePage,
Commpopup,
SuggestionPage,
Mytaskpopup,
Userwisepopup,
Taskgivenpopup,
Reportpopup,
AiPage,
FollowerPage,
CommfollowerPage,
CommPage,
ReportsPage,
DashmodalPage,
Dashmodal1Page,
LabelPage,
SortPage,
SortuserwisePage,
LastseenPage,
MemolistPage,
OfcmemoPage,
CommadminPage,
AdminpcPage
],
providers: [
StatusBar,
SplashScreen,
//Firebase,
Commopen,
GivenclosedtaskPage,
Userimage,
InAppBrowser,
SpeechRecognition,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
You dont have to add IonicApp in declarations array which is what your error message seems to saying:
Type IonicApp is part of the declarations of 2 modules: IonicModule and AppModule!
declarations: [
// OverlayPortal, //for aot compilation
// IonicApp , //for aot compilation for app-root.d
// ClickBlock, //for aot compilation
// Slides, //for aot compilation
IonicApp,// <-- remove this.
It should only be in bootstrap array.
IonicApp is a component and already declared inside IonicModule and needed only for bootstrapping. It is not a component to be added into declarations.
#NgModule({
declarations: [
// OverlayPortal, //for aot compilation
// IonicApp , //for aot compilation for app-root.d
// ClickBlock, //for aot compilation
// Slides, //for aot compilation
IonicApp ----> delete This line.

Npm run ionic:build --prod error

When I am trying to run npm run ionic:build --prod, it is giving me below errors:
Error: Cannot determine the module for class OverlayPortal in
F:/D/IONIC/quicktask/quicktask-web-froala/node_modules/ionic-angular/umd/components/app/overlay-portal.d.ts!
Add OverlayPortal to the NgModule to fix it. Cannot determine the module for class IonicApp in
F:/D/IONIC/quicktask/quicktask-web-froala/node_modules/ionic-angular/umd/components/app/app-root.d.ts! Add
IonicApp to the NgModule to fix it. Cannot determine the module for class ClickBlock in
F:/D/IONIC/quicktask/quicktask-web-froala/node_modules/ionic-angular/umd/components/app/click-block.d.ts!
Add ClickBlock to the NgModule to fix it. Cannot determine the module for class Slides in
F:/D/IONIC/quicktask/quicktask-web-froala/node_modules/ionic-angular/umd/components/slides/slides.d.ts! Add
Slides to the NgModule to fix it.
What do I do to build using --prod. I have done npm install again, updated app/scripts, don't know what else is needed.
Find below my app.module.ts
app.module.ts
import { BrowserModule } from '#angular/platform-browser';
import { ErrorHandler, NgModule } from '#angular/core';
import { App, NavController, IonicErrorHandler, IonicModule,IonicApp } from 'ionic-angular'; // removed IonicApp from here
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { ListPage } from '../pages/list/list';
import { LoginPage } from '../pages/login/login';
import { NewtaskPage } from '../pages/newtask/newtask';
//import { DashboardPage } from '../pages/dashboard/dashboard';
import { TaskgivenPage } from '../pages/taskgiven/taskgiven';
import { MytaskPage } from '../pages/mytask/mytask';
import { CommunicationPage } from '../pages/communication/communication';
import { CommunicationgivenPage } from '../pages/communicationgiven/communicationgiven';
import { CommunicationreportPage } from '../pages/communicationreport/communicationreport';
import { GivencommunicationclosedPage } from '../pages/givencommunicationclosed/givencommunicationclosed';
import { TestPage } from '../pages/test/test';
import { LogoutPage } from '../pages/logout/logout';
import { MyclosedtaskPage } from '../pages/myclosedtask/myclosedtask';
import { GivenclosedtaskPage } from '../pages/givenclosedtask/givenclosedtask';
import { ReporttoPage } from '../pages/reportto/reportto';
import { SlidePage } from '../pages/slide/slide';
import { StatusBar } from '#ionic-native/status-bar';
import { SplashScreen } from '#ionic-native/splash-screen';
//import { Firebase } from '#ionic-native/firebase';
import { SpeechRecognition } from '#ionic-native/speech-recognition';
import { Headers, Http, HttpModule ,Response } from '#angular/http';
import { IonicStorageModule } from '#ionic/storage';
import { TimeAgoPipe } from 'time-ago-pipe';
import {Commopen} from '../pages/givencommunicationclosed/commopen';
import { Userimage } from '../pages/dashboard2/userimage';
import { MycommclosedPage } from '../pages/mycommclosed/mycommclosed';
import { Dashboard2Page } from '../pages/dashboard2/dashboard2';
import { MytaskuserwisePage } from '../pages/mytaskuserwise/mytaskuserwise';
import { ProfilePage } from '../pages/profile/profile';
import { PaymentPage } from '../pages/payment/payment';
import { InAppBrowser } from '#ionic-native/in-app-browser';
import { InfoPage } from '../pages/info/info';
import { PerformancePage } from '../pages/performance/performance';
import { PopoverPage } from '../pages/communicationgiven/popover';
import { Updatepopup} from '../pages/communicationgiven/updatepopup';
import { TimelinePage } from '../pages/timeline/timeline';
import { Commpopup } from '../pages/timeline/commpopup';
import {SearchPage} from '../pages/search/search';
import {SuggestionPage} from '../pages/suggestion/suggestion';
import {Mytaskpopup} from '../pages/mytask/mytaskpopup';
import {Userwisepopup} from '../pages/mytaskuserwise/userwisepopup';
import {Taskgivenpopup} from '../pages/taskgiven/taskgivenpopup';
import {Reportpopup} from '../pages/reportto/reportpopup';
import {FollowerPage} from '../pages/follower/follower';
import {CommfollowerPage} from '../pages/commfollower/commfollower';
import { CommPage } from '../pages/comm/comm';
import {ReportsPage} from '../pages/reports/reports';
import { DashmodalPage } from '../pages/dashmodal/dashmodal';
import { Dashmodal1Page } from '../pages/dashmodal1/dashmodal1';
import { LabelPage } from '../pages/label/label';
import { SortPage } from '../pages/sort/sort';
import { SortuserwisePage } from '../pages/sortuserwise/sortuserwise';
import { LastseenPage } from '../pages/lastseen/lastseen';
import { MemolistPage } from '../pages/memolist/memolist';
import { OfcmemoPage } from '../pages/ofcmemo/ofcmemo';
import { CommadminPage } from '../pages/commadmin/commadmin';
import { AdminpcPage } from '../pages/adminpc/adminpc';
import {AiPage} from '../pages/ai/ai';
import { Autosize } from '../directives/autosize/autosize';
// Import Froala Editor.
import "froala-editor/js/froala_editor.pkgd.min.js";
import { NoSanitizePipe } from '../pipes/no-sanitize/no-sanitize';
// Import Angular2 plugin.
import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
import {Nl2BrPipeModule} from 'nl2br-pipe';
import {LinkyModule} from 'angular-linky';
//Search
import { SelectSearchableModule } from 'ionic-select-searchable';
// for ionic build --prod errors or aot compilation
// import { OverlayPortal } from '../../node_modules/ionic-angular/umd/components/app/overlay-portal.d';
//import { IonicApp } from '../../node_modules/ionic-angular/umd/components/app/app-root.d';
//import { ClickBlock } from '../../node_modules/ionic-angular/umd/components/app/click-block.d';
//import { Slides } from '../../node_modules/ionic-angular/umd/components/slides/slides.d';
import { FilterArrayPipe } from '../pages/dashboard2/filterpipe';
import {IonicPage, NavParams, Slides} from 'ionic-angular';
#NgModule({
declarations: [
// OverlayPortal, //for aot compilation
// IonicApp , //for aot compilation for app-root.d
// ClickBlock, //for aot compilation
// Slides, //for aot compilation
IonicApp,
FilterArrayPipe, //for aot compilation
TimeAgoPipe,
MyApp,
HomePage,
ListPage,
LoginPage,
NewtaskPage,
// DashboardPage,
TaskgivenPage,
MytaskPage,
CommunicationPage,
CommunicationgivenPage,
CommunicationreportPage,
GivencommunicationclosedPage,
TestPage,
LogoutPage,
MyclosedtaskPage,
GivenclosedtaskPage,
ReporttoPage,
Dashboard2Page,
MytaskuserwisePage,
MycommclosedPage,
ProfilePage,
PaymentPage,
InfoPage,
SlidePage,
PerformancePage ,
PopoverPage,
Updatepopup,
SearchPage,
TimelinePage,
Commpopup,
SuggestionPage,
Mytaskpopup,
Userwisepopup,
Taskgivenpopup,
Reportpopup,
AiPage,
Autosize,
NoSanitizePipe,
FollowerPage,
CommfollowerPage,
CommPage,
ReportsPage,
DashmodalPage,
Dashmodal1Page,
LabelPage,
SortPage,
SortuserwisePage,
LastseenPage,
MemolistPage,
OfcmemoPage,
CommadminPage,
AdminpcPage,
//OverlayPortal
],
imports: [
BrowserModule,
HttpModule,
Nl2BrPipeModule,
LinkyModule,
SelectSearchableModule,
IonicModule.forRoot(MyApp),
FroalaEditorModule.forRoot(),
FroalaViewModule.forRoot(),
IonicStorageModule.forRoot()
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage,
ListPage,
LoginPage,
NewtaskPage,
// DashboardPage,
TaskgivenPage,
MytaskPage,
CommunicationPage,
CommunicationgivenPage,
CommunicationreportPage,
GivencommunicationclosedPage,
TestPage,
LogoutPage,
MyclosedtaskPage,
GivenclosedtaskPage,
ReporttoPage,
Dashboard2Page,
MytaskuserwisePage,
MycommclosedPage,
ProfilePage,
PaymentPage,
InfoPage,
SlidePage,
PerformancePage,
PopoverPage,
Updatepopup,
SearchPage,
TimelinePage,
Commpopup,
SuggestionPage,
Mytaskpopup,
Userwisepopup,
Taskgivenpopup,
Reportpopup,
AiPage,
FollowerPage,
CommfollowerPage,
CommPage,
ReportsPage,
DashmodalPage,
Dashmodal1Page,
LabelPage,
SortPage,
SortuserwisePage,
LastseenPage,
MemolistPage,
OfcmemoPage,
CommadminPage,
AdminpcPage
],
providers: [
StatusBar,
SplashScreen,
//Firebase,
Commopen,
GivenclosedtaskPage,
Userimage,
InAppBrowser,
SpeechRecognition,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
My ionic info:
cli packages: (C:\Users\jessica\AppData\Roaming\npm\node_modules)
#ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
#ionic/app-scripts : 3.1.9
Cordova Platforms : android 6.2.3 browser 5.0.1
Ionic Framework : ionic-angular 3.8.0
System:
Android SDK Tools : 25.2.5
Node : v6.10.3
npm : 5.4.2
OS : Windows 8.1
Environment Variables:
ANDROID_HOME : C:\Program Files (x86)\Android\android-sdk
Misc:
backend : legacy
The issue with AOT build is that, you have many plugins which are outdated and do not support AOT compilation.
In order to optimize, you can check for GZIP. This should reduce your load time significantly. GZIP needs to be done from server side and has nothing to do with your Frontend code.

how to get realtime JSON from endpoint in Ionic App

Followed the content of the url to implement dynamic menu items using JSON file stored under /assets/data. The menu is working fine with stored JSON file. Now I need to dynamically retrieve the JSON of same format in real time from a Salesforce API and display its content.
Can someone please suggest what changes I need to make here? should the json path in getMainMenu() method be replaced with the actual Saleforce API?
Below is the data-service.ts
import { Injectable } from '#angular/core';
import { Http, Response } from '#angular/http';
import 'rxjs/add/operator/map';
/*
Generated class for the DataServiceProvider provider.
See https://angular.io/guide/dependency-injection for more info on providers
and Angular DI.
*/
#Injectable()
export class DataServiceProvider {
constructor(public http: Http) {
console.log('Hello DataServiceProvider Provider');
}
getMainMenu(){
return this.http.get('assets/data/mainmenu.json')
.map((response:Response)=>response.json().Categories);
}
}
and app.component.ts
import { Component, ViewChild } from '#angular/core';
import { Nav, Platform } from 'ionic-angular';
import { StatusBar } from '#ionic-native/status-bar';
import { SplashScreen } from '#ionic-native/splash-screen';
import { HomePage } from '../pages/home/home';
import { ListPage } from '../pages/list/list';
import { DataServiceProvider } from '../providers/data-service/data-service'
#Component({
templateUrl: 'app.html'
})
export class MyApp {
#ViewChild(Nav) nav: Nav;
rootPage: any = HomePage;
pages: any[]; //Array<{title: string, component: any}>;
mainmenu: any[];
constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen, public dataService: DataServiceProvider) {
this.initializeApp();
this.dataService.getMainMenu().subscribe((Response)=>{
this.mainmenu = Response;
console.log(this.mainmenu);
});
// used for an example of ngFor and navigation
this.pages = [
{ title: 'Home', component: HomePage },
{ title: 'List', component: ListPage }
];
}
initializeApp() {
this.platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
openPage(page) {
// Reset the content nav to have just this page
// we wouldn't want the back button to show in this scenario
this.nav.setRoot(page.component);
}
toggleSection(i) {
this.mainmenu[i].open = !this.mainmenu[i].open;
};
toggleItem(i,j) {
this.mainmenu[i].SubCategories[j].open = !this.mainmenu[i].SubCategories[j].open;
};
}
It looks like you will need to update the url in the getMainMenu method to that of your api. There might be some other changes you will need to make, such as adding authentication headers, but if the data coming from the api is the same as whats stored in the assets folder, your component shouldn't care "where" the data comes from.