zoukankan      html  css  js  c++  java
  • ember.js:使用笔记4 数组数据的分组显示

      除了之前介绍的将数组数据在一个页面中输出的方法,还可以将数组数据分组,按照点击,在不同页面中分别显示,方法为:

    Model:

    例如:Table

    Router:

    设置一个父对象和子对象设置:

    this.resource("tables",function() {
      this.resource("table",{path:"/:table_id"}); //依照id输出 });

    Route:

    App.TablesRoute = Em.Route.extend({
    	model: function() {
    		return this.store.findAll("table");
    	}
    });
    
    App.TableRoute = Em.Route.extend({
    	model: function(params) {
    		return this.store.find("table",params.table_id);
    	}
    });
    

    Template:

    • tables:
      {{#each}}
        {{#link-to "table" this }}{{name}}{{/link-to}}  //注意this
      {{/each}}
    
    • table:  单个对象输出方式

    Controller:

     注意此时必须添加table的控制器,否则会出错。

    App.TableController = Em.ObjectController.extend({
    
    });
    

      

  • 相关阅读:
    haproxy的使用
    zookeeper 的多线程和单线程库使用对比
    zookeeper 简介
    将博客搬至CSDN
    Sublime Text 添加eclipse快捷键
    Atom编辑器添加eclipse快捷键
    Linux安装mysql教程
    设计模式
    设计模式
    设计模式
  • 原文地址:https://www.cnblogs.com/jinkspeng/p/4005202.html
Copyright © 2011-2022 走看看