ember.js - Ember : loading Template not working when promise returned from Application Route

标签 ember.js routes loading

我不明白为什么在下面的场景下加载模板没有加载

App = Ember.Application.create()

App.Router.map ->
  this.resource 'dashboard', {path: "/"}

App.ApplicationRoute = Ember.Route.extend
  beforeModel: ->
    new Ember.RSVP.Promise (resolve) ->
      Ember.run.later ->
        resolve()
      , 3000

App.DashboardRoute = Ember.Route.extend      
  model: ->
    ['red', 'yellow', 'blue']

http://emberjs.jsbin.com/jageg/2/edit?html,js,output

来自documentation我了解到,如果路径为 dashboard 的路由返回一个不会立即解决的 promise ,Ember 将尝试在层次结构中找到它可以转换到的加载路由。

谢谢。

最佳答案

是的,父资源的加载路由会放到父资源的{{outlet}}中。不幸的是,您阻塞了最顶层的资源,因此 Ember 无法呈现应用程序模板,因此它无法加载路由。

如果再下一层阻塞,就会命中应用资源的加载路由,也就是loading

http://emberjs.jsbin.com/babuzi/edit?html,js,output

关于ember.js - Ember : loading Template not working when promise returned from Application Route,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26475351/

相关文章:

android - 如何制作默认的Android加载器动画?

java - URLClassloader 依赖项

ember.js - 从索引重定向到另一个路由和强制模型()

javascript - 登录后重定向到仪表板 [EMBER.JS]

Nginx - 将 www.example.com/test 重定向到 www.example.com :3000/

c# - jQuery AJAX 的 ASP.Net MVC 路由问题

ruby-on-rails - Rails 路线 :shallow => true

angularjs - 您如何检测 AngularJS 中的 HTML 渲染何时完成

ember.js - 如何访问传递给组件类内的 Ember 组件的属性?

model-view-controller - 了解 Ember View