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钩子来处理所有逻辑。?

  • 相关阅读:
    背水一战 Windows 10 (26)
    背水一战 Windows 10 (25)
    背水一战 Windows 10 (24)
    背水一战 Windows 10 (23)
    背水一战 Windows 10 (22)
    背水一战 Windows 10 (21)
    背水一战 Windows 10 (20)
    背水一战 Windows 10 (19)
    背水一战 Windows 10 (18)
    背水一战 Windows 10 (17)
  • 原文地址:https://www.cnblogs.com/xjinza/p/4702127.html
Copyright © 2011-2022 走看看