一、Routing

1. 当用户与应用程序交互时,它会经过很多状态。Ember.js为你提供了有用的工具去管理它的状态和扩展你的app。

2. 要理解为什么这是重要的,假设我们正在编写一个Web应用程序来管理一个博客。如:是当前登录的用户吗?他们是管理员用户吗?他们在看什么?是设置屏幕打开?他们正在编辑当前的提交的内容吗?

3. 在Ember.js,每一个应用程序中可能的状态是由一个URL表示的。因为我们上面问的所有的问题--我们已经登录了吗?我们在看什么?--通过路由处理器封装的网址,回答他们是既简单又准确。

4. 在任何时候,你的应用程序有一个或多个活动路由处理器。因为下面两个原因之一活动的处理程序会改变:

  • 用户和一个组件交互,它生成一个事件导致URL改变。
  • 用户手动改变URL或者在页面第一次被加载时。

5. 当当前的URL发生变化,新的活动路由处理程序可能执行一个或多个以下内容:

  • 有条件的重定向到一个新的URL。
  • 更新controller使它表示一个特定的model
  • 改变template,或者在存在的outlet中放置一个新的template

二、Logging Route Changes

随着你的app复杂性的增加,它可以帮助你清楚的看到router下什么东西正在进行。为了让Ember把过度事件输出到log,修改项目的配置文件如下:

config/environment.js

ENV.APP.LOG_TRANSITIONS = true;

三、Specifying A Root URL

如果你的Ember app是从同一域提供的多个web应用程序之一,对你的Ember app来说它可能需要向router指出什么是root URL。默认的,Ember将认为它是来自你的域的根路径。

例如,如果你想要从http://emberjs.com/blog/为你的博客的应用程序提供服务,有必要指定root URL/blog/

这可以通过设置路由器中的rootURL来实现:

app/router.js

Ember.Router.extend({
rootURL: '/blog/'
});

4.1 Routing -- Introduction的更多相关文章

  1. A Quick Introduction to Linux Policy Routing

    A Quick Introduction to Linux Policy Routing 29 May 2013 In this post, I’m going to introduce you to ...

  2. OVN实战---《An Introduction to OVN Routing》翻译

    Overview 在前面一篇文章的基础上,现在我将通过OVN创建一个基础的三层网络.创建的最终结果将是一对logical switches通过一个logical router相连.另外,该路由器会通过 ...

  3. 000.Introduction to ASP.NET Core--【Asp.net core 介绍】

    Introduction to ASP.NET Core Asp.net core 介绍 270 of 282 people found this helpful By Daniel Roth, Ri ...

  4. RabbitMQ消息队列(一): Detailed Introduction 详细介绍

     http://blog.csdn.net/anzhsoft/article/details/19563091 RabbitMQ消息队列(一): Detailed Introduction 详细介绍 ...

  5. Introduction - SNMP Tutorial

    30.1 Introduction In addition to protocols that provide network level services and application progr ...

  6. Service Station - An Introduction To RESTful Services With WCF

    Learning about REST An Abstract Example Why Should You Care about REST? WCF and REST WebGetAttribute ...

  7. [AngularJS] Introduction to ui-router

    Introduce to basic $stateProvider.state() with $stateParams services. Understand how nested router w ...

  8. Design and Implementation of a Routing Control Platform阅读笔记

    Design and Implementation of a Routing Control Platform   0.Abstract 1.Introduction 2.Interoperating ...

  9. Central Control Over Distributed Routing阅读笔记

    Central Control Over Distributed Routing 0.ABSTRACT1.Introduction2.Flexible Fibbing3.Augmenting Topo ...

随机推荐

  1. mybatis由浅入深day02_9.3.5使用生成的代码_9.4逆向工程注意事项

    9.3.5 使用生成的代码 需要将生成工程中所生成的代码拷贝到自己的工程中. 拷这4个到我们原来的spring_mybatis1216工程下 ItemsMapper.java package cn.i ...

  2. 九度 1500:出操队形(LIS变形)

    题目描述: 在读高中的时候,每天早上学校都要组织全校的师生进行跑步来锻炼身体,每当出操令吹响时,大家就开始往楼下跑了,然后身高矮的排在队伍的前面,身高较高的就要排在队尾.突然,有一天出操负责人想了一个 ...

  3. Emulator Error: Could not load OpenGLES emulation library: Could not load DLL!

    Copy the file below from SDK\tools\lib to SDK\tools. libEGL_translator.dlllibGLES_CM_translator.dlll ...

  4. Discuz! X2验证码的产生及验证

    http://www.mcqyy.com/wenku/jiaocheng/jzjc/cjc/106729.html http://blog.sina.com.cn/s/blog_4acbd39c010 ...

  5. nil、Nil、NULL与NSNull的区别及应用

      总结 nil:OC中的对象的空指针 Nil:OC中类的空指针 NULL:C类型的空指针 NSNull:数值类的空对象 详细解析应用如下: 1.nil 指向一个对象的指针为空 在objc.h中的定义 ...

  6. Docker源码分析(七):Docker Container网络 (上)

    1.前言(什么是Docker Container) 如今,Docker技术大行其道,大家在尝试以及玩转Docker的同时,肯定离不开一个概念,那就是“容器”或者“Docker Container”.那 ...

  7. WCF(四) 深入契约

    服务契约中的请求-响应操作 1.请求-响应模式 [OperationContract]//1默认就是 请求-相应 Requst- Replay DateTime GetDateTime(); [Ope ...

  8. java如何计算两个日期之间相差多少天?

    java如何计算两个日期之间相差多少天? public static void main(String [] args) { Date now = new Date(); Calendar cal = ...

  9. JavaScript获取地址栏的参数!

    第一种方式:手动解析 “location”对象 console.log(window.location); 使用这个对象做跳转: window.location.href=""; ...

  10. 学习认识Spring原理

    学习认识Spring原理 Spring 是一种业务层框架.搭建Spring框架需要Spring开发包和commons-logging包.Spring的核心思想是控制反转也称依赖注入(创建者--(实例) ...