I don't know how to import plugins for main.js file in ionic


Previously i had done coding in Html and Typescript files.
At that time i had imported plugins like below code

import { ToastController,LoadingController } from 'ionic-angular';

But according to my project requirement we are making changes in main.js file.
Am using
Android platform
IDE: Android Studio

Can any one guide me that how to use plugins in main.js file in Ionic.


as far as I know, main.js is generated while runtime. You don’t “change” it.
Your import line seems ok.

Imagine you want to use ToastController in your homepage.html.

import { ToastController } from 'ionic-angular';
constructor(public toastCtrl: ToastController){

Then call it like:

 let toast = this.toastCtrl.create({
    message: 'User was added successfully',
    duration: 3000,
    position: 'top'

  toast.onDidDismiss(() => {
    console.log('Dismissed toast');



Thanks for your response.
i know typescript format coding
There is any way to import plugin for main.js file.


Ionic task automation is based on Ionic App Scripts. Scripts are configured in your project’s package.json file.

If you want a .ts file to be included (e.g., “src/**/*.ts” as per the default tsconfig.json) in your build, place it in your project’s /src folder and it will be included in the generated /www/build/main.js.

BTW, ToastController and LoadingController are components not (Cordova) plugins.