angular2组件中定时刷新并清除定时器
来源:互联网 发布:淘宝店铺升天猫费用 编辑:程序博客网 时间:2024/06/06 23:25
import { Component,OnInit,ChangeDetectionStrategy,ChangeDetectorRef,OnDestroy} from "@angular/core";
@Component({
changeDetection:ChangeDetectionStrategy.OnPush
})
export class xxxComponent{
private timer;
constructor(private ref : ChangeDetectorRef){
this.timer = setInterval(()=>{
this.ref.detechChanges();//检测变化
},5000)
}
//销毁组件时清除定时器
ngOnDestroy(){
if(this.timer){
clearInterval(this.timer);
}
}
}
阅读全文
5 0
- angular2组件中定时刷新并清除定时器
- C# 定时器定时刷新数据库并显示
- 自动刷新并定时跳转
- ionic中定时刷新
- javascript中定时器,主要用来实现局部刷新技术,或者定时调用某方法
- angular2 组件
- angular2 组件
- angular2中父子组件的数据传递
- 简单的定时刷新和周期刷新的定时器
- oralce清除归档日志,并定时制作window定时任务
- 根据需求实现页面无动态定时刷新、清除定时刷新功能
- Angular2部署在IIS中解决404刷新问题
- Angular2.0如何把CSS样式加载进组件中?
- Angular2 ng-content 在组件中嵌入内容
- Angular2 ng-content 指令在组件中嵌入内容
- angular2 中使用第三方组件样式调整
- ArcEngine中清除选择集刷新问题
- Unity中定时执行事件的定时器
- eclipse安装JAVA反编译插件
- Android app\build\intermediates\res\merged\debug\values-v23\values-v23.xml 编译出错的问题
- PAT甲级真题及训练集(20)--1086. Tree Traversals Again (25)(前序,中序建二叉树,很重要!)
- 重载(overload)+数组 内存的划分
- echarts x轴文字显示不全(xAxis文字倾斜比较全面的3种做法值得推荐)
- angular2组件中定时刷新并清除定时器
- 在线字体转换
- Python 面试题整理
- ORACLE中dba,user,v$等开头的常用表和视图
- 表格或div被撑开的解决办法
- elasticsearch5.4版本 head插件正确的打开方式。。。
- BZOJ 2190: [SDOI2008]仪仗队 欧拉函数
- C++递归算法之爬楼梯
- poi导出excel