和配置块不同,运行块在注入器创建之后被执行,它是所有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. sublime markdown 设置

    安装Markdown Preview 修改用户配置文件(代码高亮): { "enable_highlight": true } 快捷键: ctrl+b 生成html文档 安装Omn ...

  2. 记一次搭建vsftp服务器坑

    避免踩坑,特此记录... yum -y install vsftpd useradd -d /www -s /sbin/nologin sui # 修改vsftpd配置文件/etc/vsftpd/vs ...

  3. windows 下的常用工具

    网址:http://cmder.net/ 如果vim乱码  命令行输入  set LC_ALL=zh_CN.UTF8 添加cmder到鼠标右键  c://安装目录/Cmder.exe /REGISTE ...

  4. Vue为v-html中标签添加CSS样式

    在最近的vue项目中遇到的问题:v-html渲染的富文本,无法在样式表中修改样式: <template> <div class="msgHtmlBox" v-ht ...

  5. Weblogic项目部署教程

    说明: 其实Weblogic是允许直接以文件夹形式发布项目的,WAR包和文件夹发部的效果没有什么区别. 对于Eclipse项目,导出的WAR包其实确实只是项目下的WebContent文件夹中的内容,所 ...

  6. jedata日期控件的开始结束日期设置

    <span class="wstxt">开始日期:</span><input type="text" class="wo ...

  7. axios 参数为payload的解决方法

    1. 添加头部headers headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, axios.post(url, {a ...

  8. LY.JAVA面向对象编程.包的概述、导包

    2018-07-18 08:46:57 导包:

  9. 首席科学家马丁•福勒(Martin Fowler)

    现任思特沃克公司首席科学家的马丁·福勒先生是当今世界软件开发领域最具影响力的五位大师之一.作为一位敏捷软件开发方法的早期开拓者,福勒先生对IT 业的影响是不可估量的. 思特沃克公司是一家跨国专业IT ...

  10. InterBase 数据库与驱动 版本不同

    [Window Title] Project1 - Delphi 10.1 Berlin - Unit1 [Content] Failed: "unsupported on-disk str ...