Clear interval not working ionic2


#1

Every variation of clearinterval doesn’t work…
I have timer scripts on one tab, that shouldn’t work on another tab… don’t know why thats
not build in

here’s my code

             this.zone.run(()=>{
           this.home_game_timer = setInterval(()=>{

                var link = 'https://gamerholic.com/****';
                var data = JSON.stringify({game:this.game,uid:this.uid});
                let headers = new Headers({ 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8' });
                let options = new RequestOptions({ headers: headers });
                return this.http.post(link, data,options)
                //print php error
                //.subscribe(data => {console.log(data._body)})
                 //get json response
                  .map(data => data.json())
                  .catch(this.handleError)
                  .subscribe((data) =>{
                    this.timer_data = data,
                    this.list_players = data
                    //console.log(JSON.stringify(data))
                    console.log("home ts 164" +JSON.stringify(this.timer_data))
                  }
                  //console.log(this.timer_data)
                )
                  //

           },1000)
        })

on leave clear the interval

          ionViewWillLeave() {
         
         clearInterval(this.home_game_timer);
       

       }

doesn’t work… what am I doing wrong?


#2

Did you try to put the NgZone inside the Interval ?