小编SUB*_*DAL的帖子

clearinterval在ngOnDestroy()中不起作用

我的ngOndestroy正在调用其他路由导航,但它没有在方法中执行clearInterval.我哪里弄错了?它在后台运行,而我在其他组件中.

timer:any;

ngOnInit() {
  this.timer= this.interval();
};

 ngOnDestroy(){
    clearInterval(this.timer);
   console.log("Inside Destroy");


 }

interval(){
  setInterval(()=>{
    this.getData();
  },20000)
}
 getData(){
   this.dataservice.getdata()
      .subscribe(users=>{
      this.datas=users;
      console.log(this.datas);
    })
 }
Run Code Online (Sandbox Code Playgroud)

javascript angular

10
推荐指数
1
解决办法
597
查看次数

角度模板的数学运算

每当我在视图模板中尝试类似的操作时,它都会按预期工作。

{{20*30}}

但每当我尝试

{{somevalue1*somevalue2}}

其中somevalue1somevalue2两者都来自组件并且somevalue2来自 api 并且它位于数组内,它显示 NaN。

该怎么处理呢?

是因为 String 值吗?

如何将其转换为模板中的数字?

javascript angular2-template angular

1
推荐指数
1
解决办法
9740
查看次数

标签 统计

angular ×2

javascript ×2

angular2-template ×1