zoukankan      html  css  js  c++  java
  • Emberjs路由

    App.Router.map(function() {
      this.resource('topCharts', function() {
        this.route('choose', { path: '/' });
        this.route('albums');
        this.route('songs');
        this.route('artists');
        this.route('playlists');
      });
    });
    
    App.TopChartsChooseRoute = Ember.Route.extend({
      beforeModel: function() {
        var lastFilter = this.controllerFor('application').get('lastFilter');
        this.transitionTo('topCharts.' + (lastFilter || 'songs'));
      }
    });
    
    // Superclass to be used by all of the filter routes below
    App.FilterRoute = Ember.Route.extend({
      activate: function() {
        var controller = this.controllerFor('application');
        controller.set('lastFilter', this.templateName);
      }
    });
    
    App.TopChartsSongsRoute = App.FilterRoute.extend();
    App.TopChartsAlbumsRoute = App.FilterRoute.extend();
    App.TopChartsArtistsRoute = App.FilterRoute.extend();
    App.TopChartsPlaylistsRoute = App.FilterRoute.extend();
    

      

    model钩子包含了基于承诺暂停过渡的许多应用场景,但是有的时候还是需要beforeModelafterModel这两个钩子来提供帮助。最常见的原因是通过{{link-to}}或者{{transitionTo}}(最为URL改变导致的过渡的对比)过渡到一个具有动态URL端,这时将过渡到的路由的模型早早就被指定了(例如{{#link-to 'article' article}}或者this.transitionTo('article', article)),这种情况下,model钩子并不会被调用。当路由正在收集所有路由的模型来执行过渡时,就需要使用beforeModelafterModel钩子来处理所有逻辑。?

  • 相关阅读:
    iOS ----------各种判断
    iOS----------常见宏定义
    iOS-----------进阶书籍收藏
    iOS----------YYModel
    Mac 系统占用100g的解决办法
    MAC终端常用语法
    iOS----------网络请求错误
    【2020Python修炼记】前端开发之 CSS基础和CSS选择器
    【2020Python修炼记】前端开发之 HTML常用标签汇总
    【教程干货】前端学习网站·资源
  • 原文地址:https://www.cnblogs.com/xjinza/p/4702127.html
Copyright © 2011-2022 走看看