简体   繁体   English

创建Ember.js应用

[英]Creating Ember.js application

I am trying to create application with Ember.js, but without storing the data, i want to have all my routes and templates defined before. 我正在尝试使用Ember.js创建应用程序,但是在不存储数据的情况下,我想先定义所有的路由和模板。 For example, i want to have menu and when clicking on it i want different parts of code rendered, but without storing data with ember data or whatever else, like it is in code below. 例如,我想要菜单,单击该菜单时,我希望呈现代码的不同部分,但不存储带有余烬数据或其他任何数据的数据,就像下面的代码中那样。 Does anyone have tutorial or code that helps me with this? 有人有帮助我的教程或代码吗?

 App.IndexRoute = Ember.Route.extend({
   model : function(){
    var stories = this.get('store').findAll('story');
    return stories;
  }
});

If you want hardcoded data, just return whatever objects/arrays you want to use from the model hook. 如果您想对数据进行硬编码,则只需从模型挂钩中返回要使用的任何对象/数组即可。

App.IndexRoute = Ember.Route.extend({
   model : function() {
    return {
      title: "Some title",
      whatever: []
    };
  }
});

If you don't need data at all, don't return anything. 如果您根本不需要数据,请不要返回任何内容。 You should, however, still have model: hook, because otherwise Ember will try to create one for you, using main data store. 但是,您应该仍然具有model: hook,因为否则Ember将尝试使用主数据存储为您创建一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM