我正在尝试使用以下代码进行订阅,但它不起作用.
import { Platform } from 'ionic-angular'; @Page({ templateUrl: 'build/pages/test.html',}) export class Test{ constructor(private platform: Platform) { this.platform.pause.subscribe(() => { console.log('paused') }); } }@H_404_2@我正在使用Ionic 2和TypeScript,Angular 2.作为platform.pause是Ionic 2提供的EventEmitter,我想它应该可以订阅.但是,当我将应用程序放到后台时,不会触发console.log(‘pause’).
我应该向提供商或类似的东西添加平台吗?另外,this.platform不为null. this.platform.ready().then(()=> {console.log(‘ready’)})完美无缺.