I'm new to Ionic and trying to make use of the background plugin , I have the following simple and functional builder for my app:
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();
});
}
}
It works gem! Now, I want to add the following line below the this.backgroundMode.enable();
:
$timeout(function() {
this.backgroundMode.moveToBackground();
}, 500);
The problem is that I don't know how to import $timeout
, just like $scope
, which are variables that are passed automatically with controllers, but here I have no idea how to import or declare them. I tried adding them as constructor parameter, but it didn't work.
From already thank you very much!
you can import
And use it:
Or as you propose since it changes the syntax