I am new to Ionic and I am trying to use the background plugin, I have the following simple and functional my application builder:
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { BackgroundMode } from '@ionic-native/background-mode';
import { TabsPage } from '../pages/tabs/tabs';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage:any = TabsPage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, private backgroundMode: BackgroundMode) {
platform.ready().then(() => {
statusBar.styleDefault();
splashScreen.hide();
// Configuracion de background
this.backgroundMode.enable();
});
}
}
Gem works! Now, I want to add the following line below this.backgroundMode.enable();
:
$timeout(function() {
this.backgroundMode.moveToBackground();
}, 500);
The problem is that I do not know how to import $timeout
, like $scope
, which are variables that are automatically passed with controllers, but here I have no idea how to import or declare them. I tried adding them as a constructor parameter, but it did not work.
Thank you very much!