1. 简单使用

var app = angular.module("app",[]);
app.controller("AppCtrl", function($q. $interval){
var timer = $interval(function(){
},1000,3);// 表示每一秒执行一次,执行三次
timer.then(success); // 三次成功后调用对应的函数
function success(){
console.log("done");
}
})

2.错误的处理,和每次调用的处理

var timer = $interval(function(){},100, 10);
timer.then(success, error, notify);
function success(){
console.log("done");
}
function error(){
console.log("error");
}
function notify(){
console.log("每次都更新"); // 一般来说每次的要更新的都放在这里
}

3.取消

// 通过$interval.cancle(timer);
var timer = $interval(function(){},100, 10);
this.cancel = function(){
$interval.cancel(timer);
}

angularjs-$interval使用的更多相关文章

  1. 一篇入门AngularJS

    目录 1.AngularJS 应用 2.AngularJS 指令 3.AngularJS 表达式 4.AngularJS 模型 5.AngularJS 控制器 6.AngularJS 作用域 7.An ...

  2. Failure to find xxx in xxx was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced @ xxx

    问题: 在linux服务器上使用maven编译war时报错: 16:41:35 [FATAL] Non-resolvable parent POM for ***: Failure to find * ...

  3. [LeetCode] Find Right Interval 找右区间

    Given a set of intervals, for each of the interval i, check if there exists an interval j whose star ...

  4. [LeetCode] Insert Interval 插入区间

    Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessa ...

  5. angularjs 中的setTimeout(),setInterval() / $interval 和 $timeout

    $interval window.setInterval的Angular包装形式.Fn是每次延迟时间后被执行的函数. 间隔函数的返回值是一个承诺.这个承诺将在每个间隔刻度被通知,并且到达规定迭代次数后 ...

  6. MySQL interval()函数

    INTERVAL(N,N1,N2,N3,..........) INTERVAL()函数进行比较列表(N,N1,N2,N3等等)中的N值.该函数如果N<N1返回0,如果N<N2返回1,如果 ...

  7. oracle11g interval(numtoyminterval())自动创建表分区

    Oracle11g通过间隔分区实现按月创建表分区 在项目数据库设计过程中由于单表的数据量非常庞大,需要对表进行分区处理.由于表中的数据是历史交易,故按月分区,提升查询和管理. 由于之前对于表分区了解不 ...

  8. maven执行报错resolution will not be reattempted until the update interval of nexus h

    maven在执行过程中抛错: 引用 ... was cached in the local repository, resolution will not be reattempted until t ...

  9. 7_nodejs angularjs

    webstrom使用: ctrl+b/点击,代码导航,自动跳转到定义 ctrl+n跳转指定类 ctrl+d复制当前行ctrl+enter另起一行ctrl+y删除当前行 ctrl+alt/shift+b ...

  10. Leetcode Insert Interval

    Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessa ...

随机推荐

  1. Hadoop和Spark的异同

    谈到大数据,相信大家对Hadoop和Apache Spark这两个名字并不陌生.但我们往往对它们的理解只是提留在字面上,并没有对它们进行深入的思考,下面不妨跟我一块看下它们究竟有什么异同. 解决问题的 ...

  2. form表单和ajax表单提交(Html.BeginForm()、Ajax.BeginForm())的差别

    有如下几种区别: 1. Ajax在提交.请求.接收时,都是异步进行的,网页不需要刷新: Form提交则是新建一个页面,哪怕是提交给自己本身的页面,也是需要刷新的: 2. A在提交时,是在后台新建一个请 ...

  3. Http请求中POST与GET的区别——前端面试

    一.原理区别 Http定义了与服务器交互的方法,其中最基本的四种是:GET,POST,PUT,DELETE,正对应着对资源的查,改,增,删.URL的全称是资源描述符,我们可以这样认为,一个URL地址, ...

  4. 我的WCF摸爬滚打之路(1)

    等了好久终于等到今天!盼了好久终于把梦实现……哈哈,仅以此歌词来庆祝我为期3天的wcf学习之路圆满结束. 今天写这个文章的目的在于记录一下我自己在学习WCF的时候碰到的一些问题,俗话说,好记心不如烂笔 ...

  5. VisualStudio2013+EF6+MySql5.5环境下配置

    看院子里对EF框架和MySql的配置文章不少,但是几乎出自一篇文章的转载,而且这篇转载的文章的也比较坑爹,下面我将介绍一下我的配置过程: 第一步:安装mysql-connector-net-6.9.9 ...

  6. Camera中对焦模式总结

    1,相机对焦模式有以下几种: auto  //自动 infinity //无穷远 macro //微距 continuous-picture //持续对焦 fixed //固定焦距   2,常见对焦模 ...

  7. 一段后台C#查询SQL Server数据库代码

    using System; using System.Data; using System.Collections.Generic; using System.Linq; using System.W ...

  8. [Android] emualtor-5554 offline的解决方法

    现象:用adb devices命令总发现emualtor-5554 offline,在.android目录下面并没有发现这个设备,没法删除.原因:有程序占用5555端口,导致adb认为5554不能作为 ...

  9. linux内核分析 第4章读书笔记

    第四章 进程调度 一.抢占与非抢占 1.非抢占式进程调度 进程会一直执行直到自己主动停止运行 2.抢占式进程调度 Linux/Unix使用的是抢占式的方式,强制的挂起进程的动作就叫做抢占. 二.进程优 ...

  10. Mono Json序列化和Windows 下的差别

    在Window下DataContractJsonSerializer 的序列化的时候 只要属性具有Get访问器就可以序列化为string 但是Mono下要想序列话 那么属性必须具有Get 和Set才能 ...