和配置块不同,运行块在注入器创建之后被执行,它是所有AngularJS应用中第一个被执行的方法
运行块通常用来注册全局的事件监听器。例如,我们会在.run()块中设置路由事件的监听器以及过滤未经授权的请求

angular.module('myApp', ['ngRoute'])
.run(function($rootScope, AuthService) {
$rootScope.$on('$routeChangeStart', function(evt, next, current) {
if (!AuthService.userLoggedIn()) {
if (next.templateUrl === 'login.html') { } else {
$location.path('/login')
}
}
})
})

run的更多相关文章

  1. can't run roscore 并且 sudo 指令返回 unable to resolve host

    I'm using ubuntu14 LTS. Problems: 1. When run roscore, got a mistake and an advice to ping the local ...

  2. DotNet Run 命令介绍

    前言 本篇主要介绍 asp.net core 中,使用 dotnet tools 运行 dotnet run 之后的系统执行过程. 如果你觉得对你有帮助的话,不妨点个[推荐]. 目录 dotnet r ...

  3. 布里斯班Twilight Bay Run半程马拉松

    自从8月3日跑了半马以后,又一鼓作气报了11月份的西昌马拉松.与第一次马拉松的只求完赛目标不同,第二次当然想取得一个更好的成绩.所以8月份练的比较猛,基本上是练2.3天休息一天,周么还要拉个长于21公 ...

  4. SVN:Previous operation has not finished; run 'cleanup' if it was interrupted

    异常处理汇总-开发工具  http://www.cnblogs.com/dunitian/p/4522988.html cleanup failed to process the following ...

  5. linux 环境下运行STS时 出现must be available in order to run STS

    linux 环境下运行ECLIPSE时 出现 “ A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be avai ...

  6. 0040 Java学习笔记-多线程-线程run()方法中的异常

    run()与异常 不管是Threade还是Runnable的run()方法都没有定义抛出异常,也就是说一条线程内部发生的checked异常,必须也只能在内部用try-catch处理掉,不能往外抛,因为 ...

  7. jBPM4.4 no jBPM DB schema: no JBPM4_EXECUTION table. Run the create.jbpm.schema target first in the install tool.

    jBPM4.4 no jBPM DB schema: no JBPM4_EXECUTION table. Run the create.jbpm.schema target first in the ...

  8. .NET跨平台之旅:探秘 dotnet run 如何运行 .NET Core 应用程序

    自从用 dotnet run 成功运行第一个 "Hello world" .NET Core 应用程序后,一直有个好奇心:dotnet run 究竟是如何运行一个 .NET Cor ...

  9. 【svn】在提交文件是报错:previous operation has not finished;run 'cleanup' if it was interrupted

    1.svn在提交文件是报错:previous operation has not finished;run 'cleanup' if it was interrupted2.原因,工作队列被占用,只需 ...

  10. svn报错cleanup failed–previous operation has not finished; run cleanup if it was interrupted的解决办法

    今天在svn提交的时候它卡顿了一下,我以为已经提交完了,就按了一下,结果就再也恢复不了,也继续不了了... 报错 cleanup failed–previous operation has not f ...

随机推荐

  1. Python3+ssl实现加密通信

    一.说明 1. python标准库ssl可实现加密通信 2. ssl库底层使用openssl,做了面向对像化改造和简化,但还是可以明显看出openssl的痕迹 3. 本文先给出python实现的soc ...

  2. Object转Integer,String

    object先转为字符串,然后通过int 的封装类(Integer)的pasreInt()方法转为int 例如: Object  ob = 123; Integer.parseInt(String.v ...

  3. 逆袭之旅DAY20.XIA.选择结构

    2018-07-16  18:50:49 本章目标: 基本if选择结构 逻辑运算符 多重if选择结构 嵌套if选择结构 什么是if选择结构: if选择结构是根据条件判断之后再做处理 import ja ...

  4. Win10系列:JavaScript多媒体

    在应用程序的日常使用中,经常会使用多媒体播放器来播放多媒体文件,包括视频.音频等,因此对于开发者来说,学习多媒体播放技术对开发应用是很有帮助的.本小节主要介绍如何使用HTML5和JavaScrip实现 ...

  5. lubuntu16.04 安装过程以及ssd测试模型的环境配置

    1.系统启动盘(ultraISO)制作启动盘, 1/5 文件->打开,打开我们的iso镜像 2/5 选择我们的u盘, 3/5 点击启动->写入硬盘映像 4/5 写入方式选择raw,格式化然 ...

  6. 使用ADO.NET访问、查询和操作数据库

    ADO.ENT的主要组件 提供两个组件,用来访问和处理数据:.NET Framework 数据程序和DataSet(数据集) .NET Framework:是专门为数据处理及快速地只进,只读访问数据而 ...

  7. bzoj1968

    题解: 显然每一个数对答案的贡献为n/i 代码: #include<bits/stdc++.h> using namespace std; int n; int main() { scan ...

  8. 关于netcore 发布到服务器的准备

    1.先cmd到指定的网站目录, 然后执行 dotnet xxx.dll, 浏览器查看 localhost:5000 确认没有问题之后才去部署到iis

  9. 2.8 C++参数初始化表

    参考:http://www.weixueyuan.net/view/6340.html 总结: 参数初始化表可以为任何数据成员进行初始化. 初始化const成员变量的唯一方法只有利用参数初始化表. 通 ...

  10. java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result异常的解决方法

    今天在写一个JAVA程序的时候出现了异常:java.lang.ArithmeticException: Non-terminating decimal expansion; no exact repr ...