0
export class HomePage 
{ 

constructor(public navCtrl: NavController, public alertCtrl: AlertController, private plt: Platform, public localNotifications: LocalNotifications,) { 
    this.plt.ready().then((rdy) => { 

     let date = new Date(); 
     let before_work_notification_time = new Date(date.setHours(7,0,0)) 


     this.localNotifications.schedule({ 
     id:1, 
     title: 'Good morning', 
     text: 'My morning notification' + before_work_notification_time.getHours(), 
     at: before_work_notification_time, 
     every: 'day', 
     data: { mydata: 'My daily before work notification'} 
     }); 
} 
} 

"ionViewDidLoad()"의 생성자 외부에서 "work_start_notification_time"값에 액세스하고 싶습니다. 할 수 있습니까? 나는 내가 만든 모든 알림 시간에 대한 그래프를 작성하려고합니다. 또는 "id"를 사용하여 만든 localnotification에 액세스 할 수 있습니까? 사전에이온 로컬 알림에서 외부의 생성자 내부 변수에 액세스하십시오.

감사합니다, SKR

답변

0
export class HomePage 
{ 

//outside scope variables 
public work_start_notification_time:any ; 

constructor() { 
    //assign a value 
this.work_start_notification_time = "somevalue"; 

} 

someMethod() 
{ 
    //access from outside constructor 

console.log(this.work_start_notification_time); 
} 
}