Javascript 扩展余烬应用程序,包括新路线,现在没有任何渲染

Javascript 扩展余烬应用程序,包括新路线,现在没有任何渲染,javascript,ember.js,Javascript,Ember.js,我正在学习余烬教程- 并对其进行了编辑,以包含新模型和路线。最初的教程是一个CRUD应用程序,供用户使用。我现在想扩展这个应用程序来处理这些用户可能学习的主题列表router.js文件现在如下所示- App.Router.map(function(){ this.resource('users', function(){ this.resource('user', { path:'/:user_id' }, function(){ this.ro

我正在学习余烬教程-

并对其进行了编辑,以包含新模型和路线。最初的教程是一个CRUD应用程序,供用户使用。我现在想扩展这个应用程序来处理这些用户可能学习的主题列表
router.js文件现在如下所示-

App.Router.map(function(){
    this.resource('users', function(){
        this.resource('user', { path:'/:user_id' }, function(){
            this.route('edit');
        });
        this.route('create');
    });

    this.resource('subjects', function(){
    this.resource('subject', {path: '/:subject_id'}, function(){
        this.route('edit');
    });
    this.route('create');
});

});
(主题是一个单独的路线,因为我现在希望能够创建单独的路线)

我添加了一个
subjects.js
模型,如下所示:

App.Subject = DS.Model.extend({
    name         : DS.attr(),
});

App.Subject.FIXTURES = [{
    id: 1,
    name: 'History',

}, {
    id: 2,
    name: 'Biology',

}];
主题控制器:

App.SubjectsController = Ember.ArrayController.extend({
    sortProperties: ['name'],
    sortAscending: true // false = descending
});
主题路线:

App.SubjectsRoute = Ember.Route.extend({
    model: function(){
        return this.store.find('subject');
    }
});
我的索引中的模板如下所示:

<script type = "text/x-handlebars" id = "subjects">
    <ul>
        {{#each subject in controller}}
            <li>{{subject.name}}</li>
        {{/each}}
    </ul>
</script>

    {{#控制器中的每个主题}
  • {{subject.name}
  • {{/每个}}

我已经添加了所有依赖项,并按照教程中描述的用户CRUD应用程序所执行的步骤进行操作,但现在当我转到浏览器时,没有任何渲染。有人知道为什么吗?

在为您介绍的教程中,有一个
缺少的
路由用于捕获错误路径,并重定向到
用户
路由,可能您需要包含它来显示某些内容,因为没有
索引
路由来显示某些初始页面

使用以下内容更新代码:

router.js

App.Router.map(function(){
  this.resource('users', function(){
    this.resource('user', { path:'/:user_id' }, function(){
      this.route('edit');
    });
    this.route('create');
  });

  this.resource('subjects', function(){
    this.resource('subject', {path: '/:subject_id'}, function(){
        this.route('edit');
    });
    this.route('create');
  });

  // this is our 404 error route - see MissingRoute just bellow
  this.route('missing', { path: '/*path' });    
});

// this handles wrong routes - you could use it to redirect to a 404 route or like here to redirect to the index page
App.MissingRoute = Em.Route.extend({
    redirect: function(){
        this.transitionTo('users.index');
    }
});

您是否在控制台中收到一些错误?您是否更改了应用程序。IndexRoute?@MárciorDriguesCorreajúnior,控制台中唯一的错误与余烬数据和引导相关dependencies@kertap,我没有App.IndexRoute文件?我应该吗?在我开始添加新内容之前,该应用程序运行良好。@bookstepher,余烬数据的控制台错误是什么?谢谢,但没有任何渲染!